aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Capture parsing errors for ActionController::ParamsWrapper#process_actionHaroon Ahmed2019-01-081-16/+17
|
* Merge pull request #34867 from bogdanvlviv/test-actionmailbox-configurationsGeorge Claghorn2019-01-041-0/+71
|\ | | | | Test Action Mailbox configurations
| * Test Action Mailbox configurationsbogdanvlviv2019-01-041-0/+71
| | | | | | | | Related to https://github.com/rails/rails/commit/0d40c62213cf0be58a470637bd364e92c5666402
* | Merge pull request #34870 from ↵Kasper Timm Hansen2019-01-041-1/+1
|\ \ | | | | | | | | | | | | bogdanvlviv/fix-new_framework_defaults_6_0.rb-file Fix `new_framework_defaults_6_0.rb` file
| * | Fix `new_framework_defaults_6_0.rb` filebogdanvlviv2019-01-041-1/+1
| |/ | | | | | | | | `Rails.application.config.active_job.return_false_on_aborted_enqueue` should be commented as well.
* | Merge pull request #34866 from bogdanvlviv/add-activemodel_errors_of_kindRafael França2019-01-043-10/+113
|\ \ | | | | | | Add `ActiveModel::Errors#of_kind?`
| * | Add `ActiveModel::Errors#of_kind?`bogdanvlviv2019-01-043-10/+113
| | | | | | | | | | | | Related to https://github.com/rails/rails/pull/34817#issuecomment-451508668
* | | Merge pull request #34871 from bogdanvlviv/clarify-delegate_missing_toRyuta Kamizono2019-01-051-1/+1
|\ \ \ | |_|/ |/| | Clarify `delegate_missing_to` [ci skip]
| * | Clarify `delegate_missing_to` [ci skip]bogdanvlviv2019-01-041-1/+1
|/ / | | | | | | | | | | | | | | Since #34864 removed explicit receiver to clarify the purpose of `delegate_missing_to`, I think it will be better to do the same a few lines above to easier figure out that `delegate_missing_to` defines `method_missing`, `respond_to_missing?` when comparing these examples.
* | Send Active Storage jobs to dedicated queues by defaultGeorge Claghorn2019-01-045-2/+49
| | | | | | Match Action Mailbox, which sets a default queue for each of its two jobs.
* | Merge pull request #34864 from mikegee/patch-1Rafael França2019-01-041-1/+1
|\ \ | | | | | | Clarify benefit of `delegate_missing_to`
| * | Clarify benefit of `delegate_missing_to`Michael Gee2019-01-041-1/+1
|/ / | | | | Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
* | Merge pull request #34797 from ↵Eileen M. Uchitelle2019-01-045-5/+63
|\ \ | |/ |/| | | | | gsamokovarov/views-without-defined-protect-against-forgery Don't expect defined protect_against_forgery? in {token,csrf_meta}_tag
| * Don't expect defined protect_against_forgery? in {token,csrf_meta}_tagGenadi Samokovarov2018-12-275-5/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `#csrf_meta_tags` and `#token_tag` Action View helper methods are expecting the class in which are included to explicitly define the method `#protect_against_forgery?` or else they will fail with `NoMethodError`. This is a problem if you want to use Action View outside of Rails applications. For example, in #34788 I used the `#button_to` helper inside of the error pages templates that have a custom `ActionView::Base` subclass, which did not defined `#protect_against_forgery?` and trying to call the button failed. I had to dig inside of Action View to find-out what's was going on. I think we should either set a default method implementation in the helpers or check for the method definition, but don't explicitly require the presence of `#protect_against_forgery?` in every `ActionViews::Base` subclass as the errors are hard to figure out.
* | Merge pull request #34862 from bogdanvlviv/fix-i18n-guideVipul A M2019-01-041-1/+1
|\ \ | | | | | | Fix example of I18n setting in the guide [ci skip]
| * | Fix example of I18n setting in the guide [ci skip]bogdanvlviv2019-01-041-1/+1
| | | | | | | | | | | | Since #34356 logging `locale` value is more correct
* | | Merge pull request #34773 from ↵Eileen M. Uchitelle2019-01-042-0/+57
|\ \ \ | |/ / |/| | | | | | | | eileencodes/share-fixture-connections-with-multiple-handlers For fixtures share the connection pool when there are multiple handlers
| * | Share the connection pool when there are multiple handlersEileen Uchitelle2019-01-032-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In an application that has a primary and replica database the data inserted on the primary connection will not be able to be read by the replica connection. In a test like this: ``` test "creating a home and then reading it" do home = Home.create!(owner: "eileencodes") ActiveRecord::Base.connected_to(role: :default) do assert_equal 3, Home.count end ActiveRecord::Base.connected_to(role: :readonly) do assert_equal 3, Home.count end end ``` The home inserted in the beginning of the test can't be read by the replica database because when the test is started a transasction is opened byy `setup_fixtures`. That transaction remains open for the remainder of the test until we are done and run `teardown_fixtures`. Because the data isn't actually committed to the database the replica database cannot see the data insertion. I considered a couple ways to fix this. I could have written a database cleaner like class that would allow the data to be committed and then clean up that data afterwards. But database cleaners can make the database slow and the point of the fixtures is to be fast. In GitHub we solve this by sharing the connection pool for the replicas with the primary (writing) connection. This is a bit hacky but it works. Additionally since we define `replica? || preventing_writes?` as the code that blocks writes to the database this will still prevent writing on the replica / readonly connection. So we get all the behavior of multiple connections for the same database without slowing down the database. In this PR the code loops through the handlers. If the handler doesn't match the default handler then it retrieves the connection pool from the default / writing handler and assigns the reading handler's connections to that pool. Then in enlist_fixture_connections it maps all the connections for the default handler because all the connections are now available on that handler so we don't need to loop through them again. The test uses a temporary connection pool so we can test this with sqlite3_mem. This adapter doesn't behave the same as the others and after looking over how the query cache test works I think this is the most correct. The issues comes when calling `connects_to` because that establishes new connections and confuses the sqlite3_mem adapter. I'm not entirely sure why but I wanted to make sure we tested all adapters for this change and I checked that it wasn't the shared connection code that was causing issues - it was the `connects_to` code.
* | | Merge pull request #34858 from ↵Ryuta Kamizono2019-01-042-7/+3
|\ \ \ | | | | | | | | | | | | | | | | albertoalmagro/make-rails-compatible-accross-ruby-versions Make average compatible across ruby versions
| * | | Make average compatible accross Ruby versionsAlberto Almagro2019-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Ruby 2.6.0 NilClass#to_d is returning `BigDecimal` 0.0, this breaks `average` compatibility with prior Ruby versions. This patch makes `average` return `nil` in all Ruby versions when there are no rows.
| * | | Revert "Fix NumericData.average test on ruby 2.6"Alberto Almagro2019-01-041-6/+2
| | | | | | | | | | | | | | | | This reverts commit 89b4612ffc97e6648f5cf807906ae210e05acdda.
* | | | Merge pull request #34855 from bogdanvlviv/update-configuring-guideRafael França2019-01-031-2/+32
|\ \ \ \ | | | | | | | | | | Update the "Configuring Rails Applications" guide [ci skip]
| * | | | Update the "Configuring Rails Applications" guide [ci skip]bogdanvlviv2019-01-041-2/+32
| | | | | | | | | | | | | | | | | | | | Add section "Results of `load_defaults`" to the guide.
* | | | | Merge the redundant `when Symbol` case to the `when String, ...`Ryuta Kamizono2019-01-041-2/+1
| | | | |
* | | | | 2x faster `connection.type_cast`Ryuta Kamizono2019-01-041-6/+1
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `nil`, `Numeric`, and `String` are most basic objects which are passed to `type_cast`. But now each `when *types_which_need_no_typecasting` evaluation allocates extra two arrays, it makes `type_cast` slower. The `types_which_need_no_typecasting` was introduced at #15351, but the method isn't useful (never used any adapters) since all adapters (sqlite3, mysql2, postgresql, oracle-enhanced, sqlserver) still overrides the `_type_cast`. Just expanding the method would make the `type_cast` 2x faster. ```ruby module ActiveRecord module TypeCastFast def type_cast_fast(value, column = nil) value = id_value_for_database(value) if value.is_a?(Base) if column value = type_cast_from_column(column, value) end _type_cast_fast(value) rescue TypeError to_type = column ? " to #{column.type}" : "" raise TypeError, "can't cast #{value.class}#{to_type}" end private def _type_cast_fast(value) case value when Symbol, ActiveSupport::Multibyte::Chars, Type::Binary::Data value.to_s when true then unquoted_true when false then unquoted_false # BigDecimals need to be put in a non-normalized form and quoted. when BigDecimal then value.to_s("F") when nil, Numeric, String then value when Type::Time::Value then quoted_time(value) when Date, Time then quoted_date(value) else raise TypeError end end end end conn = ActiveRecord::Base.connection conn.extend ActiveRecord::TypeCastFast Benchmark.ips do |x| x.report("type_cast") { conn.type_cast("foo") } x.report("type_cast_fast") { conn.type_cast_fast("foo") } x.compare! end ``` ``` Warming up -------------------------------------- type_cast 58.733k i/100ms type_cast_fast 101.364k i/100ms Calculating ------------------------------------- type_cast 708.066k (± 5.9%) i/s - 3.583M in 5.080866s type_cast_fast 1.424M (± 2.3%) i/s - 7.197M in 5.055860s Comparison: type_cast_fast: 1424240.0 i/s type_cast: 708066.0 i/s - 2.01x slower ```
* | | | Merge pull request #34816 from ↵Rafael Mendonça França2019-01-033-1/+13
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | bogdanvlviv/add-skip-action-mailbox-option-to-rails-new-cmd Add `--skip-action-mailbox` option to `rails new`
| * | | | Add `--skip-action-mailbox` option to `rails new`bogdanvlviv2018-12-283-1/+18
| | | | | | | | | | | | | | | | | | | | Related to https://github.com/rails/rails/commit/ddaf06779aa51d5d1ca462c21c53f2ed169a0d2f
* | | | | Merge pull request #34706 from ChrisBr/instrumentation-guideGannon McGibbon2019-01-031-8/+14
|\ \ \ \ \ | |_|/ / / |/| | | | Add missing keys to ActiveSupport#instrumentation guide [skip ci]
| * | | | Add missing keys to ActiveSupport#instrumentation guide [skip ci]Christian Bruckmayer2019-01-021-8/+14
| | | | | | | | | | | | | | | | | | | | See https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L625.
* | | | | Merge pull request #33985 from eugeneius/attribute_methods_schema_cacheKasper Timm Hansen2019-01-037-2/+109
|\ \ \ \ \ | | | | | | | | | | | | Only define attribute methods from schema cache
| * | | | | Only define attribute methods from schema cacheEugene Kenny2018-09-287-2/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To define the attribute methods for a model, Active Record needs to know the schema of the underlying table, which is usually achieved by making a request to the database. This is undesirable behaviour while the app is booting, for two reasons: it makes the boot process dependent on the availability of the database, and it means every new process will make one query for each table, which can cause issues for large applications. However, if the application is using the schema cache dump feature, then the schema cache already contains the necessary information, and we can define the attribute methods without causing any extra database queries.
* | | | | | Capistrano is no longer a dominant force in the deployment strategy for new appsDavid Heinemeier Hansson2019-01-031-3/+0
| | | | | |
* | | | | | Use latest Bundleryuuji.yaginuma2019-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't need to specify the version because Bundler 2.0 released. Ref: https://bundler.io/blog/2019/01/03/announcing-bundler-2.html
* | | | | | Merge pull request #34846 from palkan/fix/ar-reaper-testRyuta Kamizono2019-01-031-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | fix activerecord reaper_test
| * | | | | | fix activerecord reaper_testVladimir Dementyev2019-01-021-1/+1
| | | | | | |
* | | | | | | Merge pull request #34841 from ↵Yuji Yaginuma2019-01-031-3/+0
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | | | | | | | | | | | | | | | bogdanvlviv/remove-mention-about-test-unit-test_case Remove mention about `Test::Unit::TestCase` [ci skip]
| * | | | | | Remove mention about `Test::Unit::TestCase` [ci skip]bogdanvlviv2019-01-021-3/+0
| | |_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | We've switched from `Test::Unit::TestCase` to `ActiveSupport::TestCase` since Rails 2.3. See https://edgeguides.rubyonrails.org/2_3_release_notes.html#other-railties-changes
* | | | | | Merge pull request #34836 from kamipo/class_level_update_without_idsRyuta Kamizono2019-01-022-1/+17
|\ \ \ \ \ \ | | | | | | | | | | | | | | Restore an ability that class level `update` without giving ids
| * | | | | | Restore an ability that class level `update` without giving idsRyuta Kamizono2019-01-022-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That ability was introduced at #11898 as `Relation#update` without giving ids, so the ability on the class level is not documented and not tested. c83e30d which fixes #33470 has lost two undocumented abilities. One has fixed at 5c65688, but I missed the ability on the class level. Removing any feature should not be suddenly happened in a stable version even if that is not documented. I've restored the ability and added test case to avoid any regression in the future. Fixes #34743.
* | | | | | | Merge pull request #34835 from gmcgibbon/fix_examples_in_log_subscriberEileen M. Uchitelle2019-01-021-3/+3
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | Fix examples in ActiveSupport::LogSubscriber docs
| * | | | | | Fix examples in ActiveSupport::LogSubscriber docsGannon McGibbon2019-01-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | [ci skip]
* | | | | | | MariaDB: Remove version checking lower the 5.5.8Ryuta Kamizono2019-01-021-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we already bumped the minimum version of MySQL to 5.5.8 at #33853.
* | | | | | | Permit sending Active Storage purge and analysis jobs to separate queuesGeorge Claghorn2019-01-017-5/+40
| | | | | | |
* | | | | | | Add assertions for `ActiveRecord::Base.current_role`Ryuta Kamizono2019-01-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the `current_role` is public API.
* | | | | | | Add test case for `preventing_writes?`Ryuta Kamizono2019-01-022-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the `preventing_writes?` is public API.
* | | | | | | Bring ActiveRecord::Core's API document back [ci skip]yuuji.yaginuma2019-01-021-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If exist `:nodoc:` before method define, it affects all subsequent method definitions.
* | | | | | | Document Action Mailbox configuration options [ci skip]George Claghorn2019-01-011-0/+23
| | | | | | |
* | | | | | | s/Active Mailbox/Action Mailbox/ [ci skip]George Claghorn2019-01-011-1/+1
| |/ / / / / |/| | | | |
* | | | | | Fix TypeError: no implicit conversion of Arel::Attributes::Attribute into ↵Ryuta Kamizono2019-01-022-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String properly This reverts 27c6c07 since `arel_attr.to_s` is not right way to avoid the type error. That to_s returns `"#<struct Arel::Attributes::Attribute ...>"`, there is no reason to match the regex to the inspect form. And also, the regex path is not covered by our test cases. I've tweaked the regex for redundant part and added assertions for the regex path.
* | | | | | :scissors:Ryuta Kamizono2019-01-021-1/+1
| | | | | | | | | | | | | | | | | | [ci skip]