aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix connection handling with three-tier configeileencodes2018-03-163-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you had a three-tier config, the `establish_connection` that's called in the Railtie on load can't figure out how to access the default configuration. This is because Rails assumes that the config is the first value in the hash and always associated with the key from the environment. With a three tier config however we need to go one level deeper. This commit includes 2 changes. 1) removes a line from `resolve_all` which was parsing out the the environment from the config so instead of getting ``` { :development => { :primary => { :database => "whatever" } }, :animals => { :database => "whatever-animals" } }, etc with test / prod } ``` We'd instead end up with a config that had no attachment to it's envioronment. ``` { :primary => { :database => "whatever" } :animals => { :database => "whatever-animals" } etc - without test and prod } ``` Not only did this mean that Active Record didn't know how to establish a connection, it didn't have the other necessary configs along with it in the configs list. So fix this I removed the line that deletes these configs. The second thing this commit changes is adding this line to `establish_connection` ``` spec = spec[spec_name.to_sym] if spec[spec_name.to_sym] ``` When you have a three-tier config and don't pass any hash/symbol/env etc to `establish_connection` the resolver will automatically return both the primary and secondary (in this case animals db) configurations. We'll get an `database configuration does not specify adapter` error because AR will try to establish a connection on the `primary` key rather than the `primary` key's config. It assumes that the `development` or default env automatically will return a config hash, but with a three-tier config we actually get a key and config `primary => config`. This fix is a bit of a bandaid because it's not the "correct" way to handle this situation, but it does solve our immediate problem. The new code here is saying "if the config returned from the resolver (I know it's called spec in here but we interchange our meanings a LOT and what is returned is a three-tier config) has a key matching the "primary" spec name, grab the config from the spec and pass that to the estalbish_connection method". This works because if we pass `:animals` or a hash, or `:primary` we'll already have the correct configuration to connect with. This fixes the case where we want Rail to connect with the default connection. Coming soon is a refactoring that should eliminate the need to do this but I need this fix in order to write the multi-db rake tasks that I promised in my RailsConf submission. `@tenderlove` and I are working on the refactoring of the internals for connection management but it won't be ready for a few weeks and this issue has been blocking progress.
* Merge pull request #32215 from M-Sayed/masterRichard Schneeman2018-03-091-2/+1
|\ | | | | Change doc for "polymorphic_path" in polymorphic_routes.rb
| * Change doc for "polymorphic_path" in polymorphic_routes.rbMahmoud2018-03-091-2/+1
| | | | | | | | | | The method 'polymorphic_path' is not using 'polymorphic_url' with `routing_type: :path` anymore in polymorphic_routes.rb
* | Update some i18n references in guides (#32182)Chris Salzberg2018-03-091-8/+17
| | | | | | | | | | | | | | * Remove reference to Globalize::Backend::Static as this class no longer exists. * Remove reference to google group * Remove confusing reference to Globalize3 * Add section on translating stored content
* | Merge pull request #32212 from dharamgollapudi/patch-6Ryuta Kamizono2018-03-091-1/+1
|\ \ | | | | | | | | | | | | Fixes a typo and updates active_job_basics.md [ci skip]
| * | Fixes a typo and updates active_job_basics.mdDharam Gollapudi2018-03-081-1/+1
| |/ | | | | Fixes a typo
* | Merge pull request #32213 from ↵Ryuta Kamizono2018-03-092-1/+6
|\ \ | |/ |/| | | | | | | yujideveloper/feature/delegate-ar-base-pick-to-all Add `delegate :pick, to: :all`
| * Add `delegate :pick, to: :all`Yuji Hanamura2018-03-092-1/+6
|/
* Merge pull request #32210 from kivikakk/uri-selective-monkeypatchAaron Patterson2018-03-081-2/+9
|\ | | | | Only apply URI.unescape monkey-patch if detected to be required
| * Only apply monkey-patch if detected to be requiredAshe Connor2018-03-091-2/+9
| | | | | | | | | | | | | | | | | | | | We test the failing case we're trying to patch; only if it throws an Exception do we patch. Currently this will *always* throw, but upstream Ruby has patched this bug: https://git.io/vAxKB Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
* | Always yield a CSP policy instanceAndrew White2018-03-083-17/+65
| | | | | | | | | | If the app has the CSP disabled globally allow a controller action to enable the policy for that request.
* | Add the ability to disable the global CSP in a controllerAndrew White2018-03-082-1/+19
| | | | | | | | | | | | | | | | e.g: class LegacyPagesController < ApplicationController content_security_policy false, only: :index end
* | Allow using inline style and script in the internal controllersyuuji.yaginuma2018-03-081-0/+13
| | | | | | | | | | | | | | | | | | | | We use inline style and script for the view held inside Rails like welcome page and mailer preview. Therefore, if inline is prohibited by CSP, they will not work properly. I think that this is not as expected.   For that reason, I have made it possible to use inline style and script regardless of application settings.
* | Quote string return values in doc examples [ci skip]Andrew White2018-03-081-2/+2
| |
* | Add example of maintaining context with `route_for`Andrew White2018-03-081-0/+6
| | | | | | | | [ci skip]
* | Merge pull request #32175 from bogdanvlviv/express-route_for-as-public-apiAndrew White2018-03-081-1/+13
|\ \ | |/ |/| Express `ActionDispatch::Routing::UrlFor#route_for` as public api
| * Express `ActionDispatch::Routing::UrlFor#route_for` as public apibogdanvlviv2018-03-071-1/+13
| | | | | | | | | | | | | | | | | | This method was added by #28462 but marked as private api. Since `route_for` looks good in pair with `ActionDispatch::Routing::Mapper::CustomUrls#direct` let's make it as public api. We use it in https://github.com/rails/rails/blob/e83575ff533690db86c92447a539d76b648e9fed/activestorage/config/routes.rb Closes #31417
* | Merge pull request #32183 from kivikakk/uri-ext-fixEileen M. Uchitelle2018-03-073-2/+12
|\ \ | | | | | | URI.unescape "extension" fails with Unicode input
| * | URI.unescape handles mixed Unicode/escaped inputAshe Connor2018-03-073-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, URI.enscape could handle Unicode input (without any actual escaped characters), or input with escaped characters (but no actual Unicode characters) - not both. URI.unescape("\xe3\x83\x90") # => "バ" URI.unescape("%E3%83%90") # => "バ" URI.unescape("\xe3\x83\x90%E3%83%90") # => # Encoding::CompatibilityError We need to let `gsub` handle this for us, and then force back to the original encoding of the input. The result String will be mangled if the percent-encoded characters don't conform to the encoding of the String itself, but that goes without saying. Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
* | | [ci skip] Hide internal docs from root AS moduleAshe Connor2018-03-061-0/+1
|/ / | | | | | | | | | | | | | | | | We have a bunch of documentation in lib/active_support/core_ext/object/json.rb which is currently appearing as documentation for the top-level ActiveSupport module. We hide it from rdoc here. Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
* | Don't call changes in `changes_applied` unless requiredSean Griffin2018-03-061-1/+3
| | | | | | | | | | | | This is an alternate implementation of #31698. That PR makes assumptions that I do not want in the code base. We can fix the performance regression with a much simpler patch.
* | Revert "PERF: Recover `changes_applied` performance (#31698)"Sean Griffin2018-03-064-45/+75
| | | | | | | | This reverts commit a19e91f0fab13cca61acdb1f33e27be2323b9786.
* | Provide an alternative PDF previewer based on PopplerTerence Lee2018-03-068-35/+104
| | | | | | | | | | | | mutool is licensed under the Affero GPL, which has strict distribution requirements. Poppler is licensed under the more liberal GPL, making it a good alternative for those who can't use mutool.
* | Update test to reflect GCS direct upload header changeGeorge Claghorn2018-03-061-1/+1
| |
* | Allow selectively purging attached blobsNicholas Shirley2018-03-063-12/+46
| |
* | Remove blank Content-Type from GCS direct upload headersGeorge Claghorn2018-03-061-1/+1
| | | | | | | | Since we started clearing the client-side blob's type in e0867b3, we no longer need to set a blank Content-Type header before issuing the direct upload request. Fixes that Safari 9 would combine the blank Content-Type header with the blank blob type to produce a Content-Type header containing a single comma, invalidating the request.
* | Merge pull request #32119 from fegorodscy/masterAndrew White2018-03-064-1/+58
|\ \ | | | | | | | | | Fix dependence on has_one/belongs_to relationships
| * | Fix dependence on has_one/belongs_to relationshipsFernando Gorodscy2018-03-064-1/+58
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a class has a belongs_to or has_one relationship with dependent: :destroy option enabled, objects of this class should not be deleted if it's dependents cannot be deleted. Example: class Parent has_one :child, dependent: :destroy end class Child belongs_to :parent, inverse_of: :child before_destroy { throw :abort } end c = Child.create p = Parent.create(child: c) p.destroy p.destroyed? # expected: false; actual: true; Fixes #32022
* | Update Gemfile.lock to reflect Capybara 3.xYuji Yaginuma2018-03-061-1/+1
| | | | | | | | Follow up of #32151
* | update comment to reflect new supported patterns [ci skip]Xavier Noria2018-03-061-0/+4
| |
* | Allow Capybara 3.x (#32151)Thomas Walpole2018-03-053-3/+3
| |
* | whitelist NULLS { FIRST | LAST } in order clausesXavier Noria2018-03-062-1/+28
| |
* | Fix purging dependent blobs when attachments aren't loadedGeorge Claghorn2018-03-054-25/+35
| |
* | Delete dependent attachments with recordGeorge Claghorn2018-03-053-2/+17
| | | | | | | | [Matt Jones & George Claghorn]
* | Update skip_after_callbacks_if_terminated documentationRafael Mendonça França2018-03-051-2/+2
|/ | | | | Now we always have a terminator, so we don't need to day the options only make sense when the `:terminator` options is specified.
* Correct the ActiveStorage::Service#download_chunk docs [ci skip]George Claghorn2018-03-051-1/+1
|
* Fix that after commit callbacks on update does not triggered when optimistic ↵Ryuta Kamizono2018-03-063-53/+42
| | | | | | | | | | | | | | | | | | locking is enabled This issue is caused by `@_trigger_update_callback` won't be updated due to `_update_record` in `Locking::Optimistic` doesn't call `super` when optimistic locking is enabled. Now optimistic locking concern when updating is supported by `_update_row` low level API, therefore overriding `_update_record` is no longer necessary. Removing the method just fix the issue. Closes #29096. Closes #29321. Closes #30823.
* Generate root-relative paths in Active Storage disk service URL methodsGeorge Claghorn2018-03-0517-74/+66
| | | | Fixes #32129.
* Merge pull request #32174 from ↵Ryuta Kamizono2018-03-061-1/+1
|\ | | | | | | | | bogdanvlviv/remove-extra-passing-arg-to-run_routes_command Remove extra arg passed to `Rails::Command::RoutesTest#run_routes_command`
| * Remove extra arg passed to `Rails::Command::RoutesTest#run_routes_command`bogdanvlviv2018-03-051-1/+1
| | | | | | | | Related to 6bd33d66dde015a55912af20b469788ba20ddb4e
* | Merge pull request #32170 from koic/deprecate_safe_level_of_erb_new_in_ruby_2_6Ryuta Kamizono2018-03-052-2/+13
|\ \ | |/ |/| Deprecate safe_level of `ERB.new` in Ruby 2.6
| * Deprecate safe_level of `ERB.new` in Ruby 2.6Koichi ITO2018-03-052-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary In a Rails application using Ruby 2.6.0-dev, when running `bin/rails g migration` with `RUBYOPT=-w`, an ERB deprecation warnings will be displayed. ```console % ruby -v ruby 2.6.0dev (2018-03-03 trunk 62644) [x86_64-darwin17] % bin/rails -v Rails 6.0.0.alpha % RUBYOPT=-w bin/rails g migration create_foos (snip) /Users/koic/src/github.com/rails/rails/railties/lib/rails/generators/migration.rb:66: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. /Users/koic/src/github.com/rails/rails/railties/lib/rails/generators/migration.rb:66: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead. /Users/koic/src/github.com/rails/rails/railties/lib/rails/generators/migration.rb:66: warning: Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead. create db/migrate/20180304002144_create_foos.rb ``` This PR suppresses the above deprecation warnings in Ruby 2.6.0-dev. This warning is due to the interface of `ERB.new` will change from Ruby 2.6. > Add :trim_mode and :eoutvar keyword arguments to ERB.new. > Now non-keyword arguments other than first one are softly deprecated > and will be removed when Ruby 2.5 becomes EOL. [Feature #14256] https://github.com/ruby/ruby/blob/2311087b685e8dc0f21f4a89875f25c22f5c39a9/NEWS#stdlib-updates-outstanding-ones-only The following addresses are related Ruby's commit. https://github.com/ruby/ruby/commit/cc777d0 Also this PR will change `ERB.new` used in `tasks/release.rb`. ### Other Information This PR uses `ERB.version` to switch `ERB.new` interface. Because Rails 6 supports multiple Ruby versions (Ruby 2.4.1 or higher), it need to use the appropriate interface. Using `ERB.version` instead of `RUBY_VERSON` is based on the following patch. https://github.com/ruby/ruby/pull/1826 This patch is built into Ruby. https://github.com/ruby/ruby/commit/40db89c0934c23d7464d47946bb682b9035411f9
* | Introduce `_update_row` to decouple optimistic locking concern from ↵Ryuta Kamizono2018-03-052-28/+45
| | | | | | | | `Persistence` module
* | Introduce `_delete_record` and use it for deleting a recordRyuta Kamizono2018-03-052-21/+23
| |
* | Prefer `_update_record` than `update_all` for updating a recordRyuta Kamizono2018-03-052-28/+35
| |
* | Refactor `_substitute_values` to be passed attribute names and valuesRyuta Kamizono2018-03-053-23/+15
| |
* | `id_in_database` should be respected as primary key value for persisted recordsRyuta Kamizono2018-03-053-2/+41
| | | | | | | | | | | | | | | | | | | | | | | | Currently primary key value can not be updated if a record has a locking column because of `_update_record` in `Locking::Optimistic` doesn't respect `id_in_database` as primary key value unlike in `Persistence`. And also, if a record has dirty primary key value, it may destroy any other record by the lock version of dirty record itself. When updating/destroying persisted records, it should identify themselves by `id_in_database`, not by dirty primary key value.
* | Handle another case where a blob might be erroneously purgedGeorge Claghorn2018-03-042-5/+22
| |
* | Fix "NameError: undefined local variable or method `host'"yuuji.yaginuma2018-03-052-1/+7
| | | | | | | | The `host` and `port` can't use this context.
* | Avoid purging attached blob when replacing it with itselfGeorge Claghorn2018-03-042-2/+18
| |