aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/railtie.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Add `config.active_record.warn_on_records_fetched_greater_than` optionJason Nochlin2015-03-251-0/+8
| | | | | | | | | When set to an integer, a warning will be logged whenever a result set larger than the specified size is returned by a query. Fixes #16463 The warning is outputed a module which is prepended in an initializer, so there will be no performance impact if `config.active_record.warn_on_records_fetched_greater_than` is not set.
* Revert "Merge pull request #15476 from JacobEvelyn/master"Jeremy Kemper2015-03-111-3/+0
| | | | | | | | | | | | | | | | This introduces undesirable `Rails.logger` formatters (such as the syslog formatter) onto a `Logger.new(STDERR)` for the console. The production logger may be going elsewhere than standard io, so we can't presume to reuse its formatter. With syslog, this causes missing newlines in the console, so irb prompts start at the end of the last log message. We can work to expose the console formatter in another way to address the original issue. This reverts commit 026ce5ddf11c4cda0aae7f33a9266e54117db318, reversing changes made to 6f0a69c5899ebdc892e2aa23e68e2604fa70fb73.
* Merge pull request #15476 from JacobEvelyn/masterRafael Mendonça França2015-02-251-0/+3
|\ | | | | | | Use logger environment settings in Rails console.
| * Use logger environment settings in Rails console.Jacob Evelyn2014-06-021-0/+3
| |
* | do not trigger AR lazy load hook before initializers ran.Yves Senn2014-11-251-2/+0
|/ | | | | | | | | | | | | [Rafael Mendonça França & Yves Senn] This require caused the `active_record.set_configs` initializer to run immediately, before `config/initializers`. This means that setting any configuration on `Rails.application.config.active_record` inside of an initializer had no effects when rails was loaded through `rake`. Introduced by #6518 /cc @rafaelfranca
* Clarify 'database does not exist' message and implementation.Jeremy Kemper2014-04-011-9/+14
| | | | | | | | | | | * Clarify what the situation is and what to do. * Advise loading schema using `rake db:setup` instead of migrating. * Use a rescue in the initializer rather than extending the error message in-place. * Preserve the original backtrace of other errors by using `raise` rather than raising again with `raise error`. References 0ec45cd15d0a2f5aebc75e23d841b6c12f3ba763
* Ensure Active Record connection consistencyschneems2014-01-091-14/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently Active Record can be configured via the environment variable `DATABASE_URL` or by manually injecting a hash of values which is what Rails does, reading in `database.yml` and setting Active Record appropriately. Active Record expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot rip out this functionality without deprecating. This presents a problem though when both config is set, and a `DATABASE_URL` is present. Currently the `DATABASE_URL` should "win" and none of the values in `database.yml` are used. This is somewhat unexpected to me if I were to set values such as `pool` in the `production:` group of `database.yml` they are ignored. There are many ways that active record initiates a connection today: - Stand Alone (without rails) - `rake db:<tasks>` - ActiveRecord.establish_connection - With Rails - `rake db:<tasks>` - `rails <server> | <console>` - `rails dbconsole` We should make all of these behave exactly the same way. The best way to do this is to put all of this logic in one place so it is guaranteed to be used. Here is my prosed matrix of how this behavior should work: ``` No database.yml No DATABASE_URL => Error ``` ``` database.yml present No DATABASE_URL => Use database.yml configuration ``` ``` No database.yml DATABASE_URL present => use DATABASE_URL configuration ``` ``` database.yml present DATABASE_URL present => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url` sub key "wins". If other paramaters `adapter` or `database` are specified in YAML, they are discarded as the `url` sub key "wins". ``` ### Implementation Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge all connection information before returning. This is achieved through a utility class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`. To understand the exact behavior of this class, it is best to review the behavior in activerecord/test/cases/connection_adapters/connection_handler_test.rb though it should match the above proposal.
* Automatically maintain test database schemaJon Leighton2014-01-021-8/+1
| | | | | | | | | | | | | | * Move check from generated helper to test_help.rb, so that all applications can benefit * Rather than just raising when the test schema has pending migrations, try to load in the schema and only raise if there are pending migrations afterwards * Opt out of the check by setting config.active_record.maintain_test_schema = false * Deprecate db:test:* tasks. The test helper is now fully responsible for maintaining the test schema, so we don't need rake tasks for this. This is also a speed improvement since we're no longer reloading the test database on every call to "rake test".
* Avoid getting redefined method warningŁukasz Strzałkowski2013-12-251-0/+1
| | | | | | | Warning: ~/projects/rails/activerecord/lib/active_record/railtie.rb:140: warning: method redefined; discarding old extend_message ~/projects/rails/activerecord/lib/active_record/errors.rb:104: warning: previous definition of extend_message was here
* Only build a ConnectionSpecification if requiredJosé Valim2013-12-241-1/+1
|
* Fix build failures related to the new ENV options in ymlJosé Valim2013-12-241-1/+1
|
* Guarantee the connection resolver handles string valuesJosé Valim2013-12-231-1/+14
| | | | | | | | | This commit also cleans up the rake tasks that were checking for DATABASE_URL in different places. In fact, it would be nice to deprecate DATABASE_URL usage in the long term, considering the direction we are moving of allowing those in .yml files.
* Tell how to Create a Database in Error Messageschneems2013-12-231-0/+8
| | | | | | | | | | | | | | | | Currently if you attempt to use a database that does not exist you get an error: ``` PG::ConnectionBad FATAL: database "db_error" does not exist ``` The solution is easy, create and migrate your database however new developers may not know these commands by memory. Instead of requiring the developer to search for a solution, tell them how to fix the problem in the error message: ``` ActiveRecord::NoDatabase: FATAL: database "db_error" does not exist Run `$ bin/rake db:create db:migrate` to create your database ``` Active Record should not know about `rake db:migrate` so this additional information needs to come from the railtie. Potential alternative implementation suggestions are welcome.
* let the sqlite task run without railsDamien Mathieu2013-08-071-0/+1
|
* Remove deprecation messages about protected_attributes and rails-observersCarlos Antonio da Silva2013-07-011-39/+0
|
* remove auto-explain-config deprecation warningYves Senn2013-07-011-11/+0
|
* Setup env and seed_loaded for DatabaseTasks outside load_configPiotr Sarnacki2013-06-231-2/+3
| | | | Those vars can be used in tasks, which not call load_config.
* Change a way ActiveRecord's config is prepared for rake tasksPiotr Sarnacki2013-06-231-10/+14
| | | | | | | | | | | | | | | | In commit d1d7c86d0 I moved setting migrations paths into activerecord's railtie to remove Rails dependency on databases.rake. However, it introduced a regression, ENGINE_PATH was not available at the moment, so engine's migrations where not added properly to paths. Fix was added at 97a4a771, but it changes a way things work from using ENGINE_PATH to APP_RAKEFILE. Additionally, the config runs when the code loads, while previously it ran in the db:load_config rake task In order to make it more in pair with original version this commit changes the config to run only on load_config task. This code uses the fact that defining a task in rake does not overwrite, but only appends. It also allows to get back to checking for ENGINE_PATH
* Check if APP_RAKEFILE is definedPiotr Sarnacki2013-05-161-1/+1
|
* Fix detection of engine in rake db:load_configJoel Cogen2013-05-161-1/+1
| | | | Broken by d1d7c86d0c8dcb7e75a87644b330c4e9e7d6c1c1
* Don't require Rails.env in order to use AR::Tasks::DatabaseTasksPiotr Sarnacki2013-04-241-0/+1
|
* Use DatabaseTasks.fixtures_path instead of FIXTURES_PATH in db.rakePiotr Sarnacki2013-04-241-0/+1
| | | | | | This will allow to set fixtures path in global config easier, it should be not needed to use FIXTURES_PATH every time user wants to load fixtures.
* Don't require having Rails.application to run database tasksPiotr Sarnacki2013-04-241-0/+12
|
* MOAR cleanups.Vipul A M2013-03-141-3/+3
|
* Remove hard coded references to Active Record in railtiesJosé Valim2013-03-021-1/+1
|
* remove AR auto-explain (config.auto_explain_threshold_in_seconds)Yves Senn2013-02-241-9/+13
| | | | | | | | | | We discussed that the auto explain feature is rarely used. This PR removes only the automatic explain. You can still display the explain output for any given relation using `ActiveRecord::Relation#explain`. As a side-effect this should also fix the connection problem during asset compilation (#9385). The auto explain initializer in the `ActiveRecord::Railtie` forced a connection.
* standardize database_configuration to a hashTerence Lee2013-02-211-3/+1
| | | | | | | make connection_url_to_hash a class method This als prevents loading database.yml if it doesn't exist but DATABASE_URL does
* Point to guides.rubyonrails.org instead of edgeguides.rubyonrails.orgSantiago Pastorino2012-12-301-2/+2
|
* Fix typo in the Observers deprecation message. [ci skip]Lucas Mazza2012-11-281-1/+1
|
* Gracefully handle upgrading apps with observersRafael Mendonça França2012-11-281-0/+12
| | | | | | Rather than just raising a NoMethodError when copying the config, this commit adds a warning message until either the rails-observers gem is installed or the relevant config options are removed.
* Remove observers and sweepersRafael Mendonça França2012-11-281-10/+0
| | | | | | | | They was extracted from a plugin. See https://github.com/rails/rails-observers [Rafael Mendonça França + Steve Klabnik]
* Don't run explain on slow queries for database adapters that don't support itBlake Smith2012-11-261-0/+7
|
* only clear caches if we are actually connected to the databaseAaron Patterson2012-11-121-2/+4
|
* Gracefully handle upgrading apps with mass assigment configsAndrew White2012-11-091-0/+27
| | | | | | | | Most apps upgrading from 3.x will have options for mass assigment in their application.rb and environments/*.rb config files. Rather than just raising a NoMethodError when copying the config, this commit adds a warning message until either the protected_attributes gem is installed or the relevant config options are removed.
* Remove ActiveRecord::ModelJon Leighton2012-10-261-6/+5
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* Should use app.paths instead of specific path.kennyj2012-10-081-1/+2
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-281-2/+2
|\ | | | | | | | | Conflicts: actionpack/lib/action_view/helpers/asset_tag_helper.rb
| * nodoc AR::Railtie [ci skip]Francesco Rodriguez2012-09-211-2/+2
| |
* | make clear that expired db/schema_cache.dump are ignoredXavier Noria2012-09-241-1/+1
|/
* removed warning: shadowing outer local variableArun Agrawal2012-09-091-1/+1
|
* Get rid of config.preload_frameworks in favor of config.eager_load_namespacesJosé Valim2012-08-211-0/+3
| | | | | | | The new option allows any Ruby namespace to be registered and set up for eager load. We are effectively exposing the structure existing in Rails since v3.0 for all developers in order to make their applications thread-safe and CoW friendly.
* The use_schema_cache_dump configuration moved to ActiveRecord.kennyj2012-08-021-15/+21
|
* Fix observers with AR::ModelJon Leighton2012-06-151-3/+4
|
* Fix config.active_record.whitelist_attributes with AR::ModelJon Leighton2012-06-151-3/+0
|
* Simplify AR configuration code.Jon Leighton2012-06-151-2/+2
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* refactorJon Leighton2012-06-151-11/+5
|
* raise error for pending migration schneems2012-06-091-0/+7
| | | can be configured by setting config.active_record.migration. Setting to :page_load will raise an error on each page refresh if there are migrations that are pending. Setting to :page_load is defaulted in development for new applications.
* Fix #5847 and #4045 on master.kennyj2012-05-301-0/+2
|
* Use runner hook to load ActiveRecord::Base.kennyj2012-05-301-0/+4
|
* Revert "Merge pull request #5995 from kennyj/fix_5847-3"José Valim2012-04-271-5/+0
| | | | | | | | Active Record should be lazy loaded and this pull request forced Active Record to always be loaded after initialization. This reverts commit 8cd14c0bc9f9429f03d1181912355d2f48b98157, reversing changes made to 2f0c8c52e66f1a2a3d1c00efc207f227124e96c2.