- 02 2月, 2019 1 次提交
-
-
由 Eileen Uchitelle 提交于
When I wrote the `connected_to` and `connects_to` API's I wrote them with the idea in mind that it didn't really matter what the handlers/roles were called as long as those connecting to the roles knew which one wrote and which one read. With the introduction of the middleware Rails begins to assume it's `writing` and `reading` and there's no room for other roles. At GitHub we've been using this method for a long time so we have a ton of legacy code that uses different handler names `default` and `readonly`. We could rename all our code but I think this is better for a few reasons: - Legacy apps that have been using multiple databases for a long time can have an eaiser time switching. - If we later find this to cause more issues than it's worth we can easily deprecate. - We won't force old apps to rewrite the resolver middleware just to use a different handler. Adding the writing_role/reading_role required that I move the code that creates the first handler for writing to the railtie. If I didn't move this the core class would assign the handler before I was able to assign a new one in my configuration and I'd end up with 3 handlers instead of 2.
-
- 01 2月, 2019 13 次提交
-
-
由 Eileen M. Uchitelle 提交于
Railties typo fixes.
-
由 alkesh26 提交于
-
由 yuuji.yaginuma 提交于
* Fix broken format. * Need to specify driver to the first argument of `driven_by`. * `add_emulation` doesn't have `device` keyword. Ref: https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/chrome/options.rb#L142-L162
-
由 Ryuta Kamizono 提交于
Related 5754a29a. And follows Ruby standard library style https://github.com/ruby/ruby/commit/3406c5d.
-
由 Ryuta Kamizono 提交于
Fix has_many through association creation
-
由 Ryuta Kamizono 提交于
Remove unused attr_writers `visitor` and `indexes`
-
由 Yuji Yaginuma 提交于
Make the backquote operator always return a string
-
由 Aaron Patterson 提交于
-
由 Ryuta Kamizono 提交于
I deprecated two unused attr_writers `visitor` and `indexes` at 8056fe0d and f4bc364f conservatively, since those are accidentaly exposed in the docs. https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/AbstractAdapter.html https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html But I've found that `view_renderer` attr_writer is removed without deprecation at #35093, that is also exposed in the doc. https://api.rubyonrails.org/v5.2/classes/ActionView/Base.html I'd like to also remove the deprecated attr_writers since I think that removing `visitor` and `indexes` attr_writers is as safe as removing `view_renderer` attr_writer.
-
由 Vipul A M 提交于
ActiveRecord typo fixes. [ci skip]
-
由 Ryuta Kamizono 提交于
ActiveStorage typo fix. [ci skip]
-
由 Ryuta Kamizono 提交于
This reverts commit ed1eda27, reversing changes made to 3d2caab7. Reason: 7c3da6e0
-
由 Ryuta Kamizono 提交于
#33729 affected the behavior of the has_many through record creation. Since #33729, the intermediate reflection of simple has_many through association has `inverse_of` to the association, it causes extra through record creation, the extra through record required valid before the association record is saved. https://github.com/rails/rails/blob/23125378673bcc606b274027666a126573e136f8/activerecord/lib/active_record/associations/has_many_through_association.rb#L95-L102 I think that #33729 need to more work to care about has_many through association, that PR should be reverted to not break existing apps.
-
- 31 1月, 2019 15 次提交
-
-
由 Akinori MUSHA 提交于
ActiveSupport overrides `` Kernel#` `` so that it would not raise `Errno::ENOENT` but return `nil` instead (due to the last statement `STDERR.puts` returning nil) if a given command were not found. Because of this, you cannot safely say somthing like `` `command`.chomp `` when ActiveSupport is loaded. It turns out that this is an outdated monkey patch for Windows platforms to emulate Unix behavior on an ancient version of Ruby, and it should be removed by now.
-
由 alkesh26 提交于
-
由 alkesh26 提交于
-
由 Yuji Yaginuma 提交于
Fix typo: inherts -> inherits [ci skip]
-
由 Abhay Nikam 提交于
-
由 Ryuta Kamizono 提交于
We enabled `Style/RedundantBegin` cop at #34764, but it is hard to detect an offence if returning value put after the block.
-
由 yuuji.yaginuma 提交于
This fixes following warning. ``` warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments. ```
-
由 Eileen M. Uchitelle 提交于
Write update_last_write_timestamp after request
-
由 Kasper Timm Hansen 提交于
ActiveModel typo fixes.
-
由 Yuji Yaginuma 提交于
Don't add `RAILS_ENV` in generate action
-
由 John Hawthorn 提交于
We need to update using the timestamp from the end of the request, not the start. For example, if a request spends 5+ seconds writing, we still want to wait another 5 seconds for replication lag. Since we now run the update after we yield, we need to use ensure to make sure we update the timestamp even if there is an exception.
-
由 alkesh26 提交于
-
由 Aaron Patterson 提交于
Tighten up the AV::Base constructor
-
由 Eileen M. Uchitelle 提交于
Part 8: Multi db improvements, Adds basic automatic database switching to Rails
-
由 Eileen Uchitelle 提交于
The following PR adds behavior to Rails to allow an application to automatically switch it's connection from the primary to the replica. A request will be sent to the replica if: * The request is a read request (`GET` or `HEAD`) * AND It's been 2 seconds since the last write to the database (because we don't want to send a user to a replica if the write hasn't made it to the replica yet) A request will be sent to the primary if: * It's not a GET/HEAD request (ie is a POST, PATCH, etc) * Has been less than 2 seconds since the last write to the database The implementation that decides when to switch reads (the 2 seconds) is "safe" to use in production but not recommended without adequate testing with your infrastructure. At GitHub in addition to the a 5 second delay we have a curcuit breaker that checks the replication delay and will send the query to a replica before the 5 seconds has passed. This is specific to our application and therefore not something Rails should be doing for you. You'll need to test and implement more robust handling of when to switch based on your infrastructure. The auto switcher in Rails is meant to be a basic implementation / API that acts as a guide for how to implement autoswitching. The impementation here is meant to be strict enough that you know how to implement your own resolver and operations classes but flexible enough that we're not telling you how to do it. The middleware is not included automatically and can be installed in your application with the classes you want to use for the resolver and operations passed in. If you don't pass any classes into the middleware the Rails default Resolver and Session classes will be used. The Resolver decides what parameters define when to switch, Operations sets timestamps for the Resolver to read from. For example you may want to use cookies instead of a session so you'd implement a Resolver::Cookies class and pass that into the middleware via configuration options. ``` config.active_record.database_selector = { delay: 2.seconds } config.active_record.database_resolver = MyResolver config.active_record.database_operations = MyResolver::MyCookies ``` Your classes can inherit from the existing classes and reimplment the methods (or implement more methods) that you need to do the switching. You only need to implement methods that you want to change. For example if you wanted to set the session token for the last read from a replica you would reimplement the `read_from_replica` method in your resolver class and implement a method that updates a new timestamp in your operations class.
-
- 30 1月, 2019 11 次提交
-
-
由 Eileen M. Uchitelle 提交于
Fix case when we want a UrlConfig but the URL is nil
-
由 Ryuta Kamizono 提交于
Remove unused code
-
由 Eileen Uchitelle 提交于
Previously if the `url` key in a config hash was nil we'd ignore the configuration as invalid. This can happen when you're relying on a `DATABASE_URL` in the env and that is not set in the environment. ``` production: <<: *default url: ENV['DATABASE_URL'] ``` This PR fixes that case by checking if there is a `url` key in the config instead of checking if the `url` is not nil in the config. In addition to changing the conditional we then need to build a url hash to merge with the original hash in the `UrlConfig` object. Fixes #35091
-
由 bogdanvlviv 提交于
- Remove `fragment_cache_key` helper declaration. It was removed in e70d3df7 - Remove `by_private_lifo`. It is unused since a7becf14
-
由 Ryuta Kamizono 提交于
Add HashWithIndifferentAccess#assoc
-
由 Ryuta Kamizono 提交于
3.5.2 (September 07, 2017) is a little older.
-
由 Ryuta Kamizono 提交于
https://travis-ci.org/rails/rails/jobs/486285170#L1349-L1366 ``` % git grep -n DrivenBySeleniumWith test/abstract_unit.rb:374:class DrivenBySeleniumWithChrome < ActionDispatch::SystemTestCase test/abstract_unit.rb:378:class DrivenBySeleniumWithHeadlessChrome < ActionDispatch::SystemTestCase test/abstract_unit.rb:382:class DrivenBySeleniumWithHeadlessFirefox < ActionDispatch::SystemTestCase test/dispatch/system_testing/screenshot_helper_test.rb:10: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:18: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:28: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:40: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:48: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:62: new_test = DrivenBySeleniumWithChrome.new("x") test/dispatch/system_testing/screenshot_helper_test.rb:76:class SeleniumScreenshotsTest < DrivenBySeleniumWithChrome test/dispatch/system_testing/system_test_case_test.rb:11:class OverrideSeleniumSubclassToRackTestTest < DrivenBySeleniumWithChrome test/dispatch/system_testing/system_test_case_test.rb:19:class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome test/dispatch/system_testing/system_test_case_test.rb:25:class SetDriverToSeleniumHeadlessChromeTest < DrivenBySeleniumWithHeadlessChrome test/dispatch/system_testing/system_test_case_test.rb:31:class SetDriverToSeleniumHeadlessFirefoxTest < DrivenBySeleniumWithHeadlessFirefox test/dispatch/system_testing/system_test_case_test.rb:49:class UndefMethodsTest < DrivenBySeleniumWithChrome ```
-
由 Ryuta Kamizono 提交于
But `NameError: uninitialized constant ActionDispatch::SystemTesting::Browser::Selenium` is pretty confused. I've little improved missing constant error to `NameError: uninitialized constant Selenium`.
-
由 Stefan Schüßler 提交于
-
由 Ryuta Kamizono 提交于
Update Sneakers to the latest version
-