aboutsummaryrefslogtreecommitdiffstats
path: root/railties
Commit message (Collapse)AuthorAgeFilesLines
* Ensure Active Record connection consistencyschneems2014-01-093-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* MySQL version 4.1 was EOL on December 31, 2009Zachary Scott2014-01-081-1/+1
| | | | We should at least recommend modern versions of MySQL to users.
* add a more restricted codepath for templates fixes #13390Aaron Patterson2014-01-082-12/+51
|
* Merge pull request #13637 from craftsmen/app-generator-minor-fixRafael Mendonça França2014-01-081-4/+4
|\ | | | | Move finish_template as the last public method defined in the generator
| * Move finish_template as the last public method in the generatorMehdi Lahmam2014-01-081-4/+4
| |
* | refactor generator tests to use block form of TempfileAaron Patterson2014-01-081-36/+30
|/
* Fix rdoc markup [ci skip]Carlos Antonio da Silva2014-01-061-1/+1
| | | | Wrapping symbols with + does not work, we must use <tt> instead.
* Add missing tests for invalid names in `rails plugin new`Robin Böning2014-01-061-0/+6
| | | | | * Test for: Invalid plugin name, because of reserved rails word. * Test for: Invalid plugin name because of constant name that is already in use.
* Add preview_path to autoload_paths in after_initializeAndrew White2014-01-041-1/+41
| | | | | | | | | | Only config.autoload_paths is frozen, so add the preview_path to ActiveSupport::Dependencies.autoload_paths directly in an after_initialize block. Also protect against a blank preview_path being added to autoload_paths which can cause a serious slowdown as Dir[] tries to load all *_preview.rb files under / Fixes #13372
* Change all "can not"s to the correct "cannot".T.J. Schuck2014-01-031-1/+1
|
* Use DATABASE_URL by defaultschneems2014-01-0212-19/+12
| | | See https://github.com/rails/rails/pull/13463#issuecomment-31480799 for full conversation.
* Automatically maintain test database schemaJon Leighton2014-01-026-5/+65
| | | | | | | | | | | | | | * 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".
* Reverse 821525e and wrap run_generator callAndrew White2014-01-021-3/+13
| | | | | | Ruby 2.1.0 includes the json gem 1.8.1 by default so we need bundler 1.5.1 for `bundle install` to work. To fix this reverse the downgrade to 1.3.5 and wrap the `run_generator` call with a block that resets `THOR_DEBUG`.
* Adding missing requireRafael Mendonça França2014-01-021-0/+1
|
* Move default production database to URL sub keyschneems2014-01-0111-12/+26
| | | | By using the URL sub key in the `database.yml` by default we are exposing the ability to set other attributes such as `pool` or `reap_frequency` without need of modifying the URL to contain non-connection specific information.
* update copyright notices to 2014. [ci skip]Vipul A M2014-01-011-1/+1
|
* Fix comment syntaxBrian Cardarella2013-12-311-1/+1
| | | | The code syntax in the comment example is invalid
* rbconfig is not used in these filesArun Agrawal2013-12-262-2/+0
| | | | remove unused requires
* Improve font of some code in API documentation [ci skip]Chun-wei Kuo2013-12-263-12/+12
| | | | | * Add "<tt>" or "+" to improve font of some code and filenames in API documentation * Does not contain wording changes
* fix 2.1.0 bug :(schneems2013-12-251-1/+1
|
* ensure environment is run before db:structure:loadschneems2013-12-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now `db:drop` depends on `load_config` since so when `db:drop` gets executed `load_config` gets run. `db:structure:load` depends on `[:environment, :load_config]`. So before it runs, it executes `environment` but because `load_config` has already executed it is skipped. Note `db:load_config` is "invoke"-d twice, but only "execute"-d once: ``` ** Invoke db:drop (first_time) ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:drop ** Invoke db:structure:load (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config ** Execute db:structure:load ``` The fix for this is making sure that the environment is run before any `load_config`: ``` ** Invoke environment (first_time) ** Execute environment ** Invoke db:drop (first_time) ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:drop ** Invoke db:structure:load (first_time) ** Invoke environment ** Invoke db:load_config ** Execute db:structure:load ```
* Partial fix of database url testsschneems2013-12-251-1/+4
| | | | | | | | Prior to #13463 when `DATABASE_URL` was set, Rails automagically used that value instead of the database.yml. There are tests in dbs_test that expect this to still be true. After that PR, `RAILS_DATABASE_URL` is expected to be read into the YAML file via ERB, this PR fixes that behavior. Note: this does not entirely fix the tests. It seems that `ActiveRecord::Tasks::DatabaseTasks.current_config` does not process the url string correctly (convert it into a hash), and ` ActiveRecord::Tasks::DatabaseTasks.structure_load(current_config, filename)` as well as other methods in `DatabaseTasks` expect a hash. It seems like we should involve the resolver somewhere in this process to correctly convert the database url, I do not know the best place for that /cc @josevalim
* Fix tests names: tokens.yml => secrets.ymlGuillermo Iguaran2013-12-251-2/+2
|
* using symbol instead of string in establish_connectionKuldeep Aggarwal2013-12-251-1/+1
|
* Revert "Ensure secret_key_base is set for all environments"José Valim2013-12-241-2/+1
| | | | | | A better solution has been pushed to master. This reverts commit 959cfcef7255bba720ce3f15323056533ea7b50a.
* Merge pull request #13472 from schneems/schneems/fix-master-database-url-testsJosé Valim2013-12-241-1/+2
|\ | | | | Fix railties tests in master
| * Fix railties tests in masterschneems2013-12-241-1/+2
| | | | | | | | | | Tests are failing due to missing env var on master https://travis-ci.org/rails/rails/jobs/15930622#L641 This adds an environment variable `ENV['RAILS_SECRET_KEY_BASE']` so these tests will pass.
* | Merge pull request #13471 from schneems/schneems/better-secrets-error-messageJosé Valim2013-12-241-1/+1
|\ \ | |/ |/| Better missing `secret_key_base` error message
| * Better missing `secret_key_base` error messageschneems2013-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the error was: ``` RuntimeError: You must set secret_key_base in your app's config ``` Will now be: ``` RuntimeError: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` ```
* | Ensure secret_key_base is set for all environmentsJosé Valim2013-12-241-1/+2
| |
* | 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-0/+18
| |
* | Update CHANGELOG [ci skip]José Valim2013-12-231-0/+5
| |
* | Use the new Resolver API in dbconsoleJosé Valim2013-12-231-3/+2
| |
* | Add examples and namespace ENV options with "RAILS_"José Valim2013-12-2312-13/+25
| |
* | Do not store production information in .yml filesJosé Valim2013-12-2312-40/+36
|/ | | | Instead, read information from environment variables.
* Add comments with urls for email previewsAndrew White2013-12-222-6/+13
|
* Use Full path to sqlite database in testsschneems2013-12-222-4/+4
|
* Fix DB Console tests schneems2013-12-211-20/+22
| | | | | | | | | | | The build is broken: https://travis-ci.org/rails/rails/builds/15824530 This commit fixes it. The problem: Sqlite expects the `database` part to be an absolute path. That prompted this change to be committed to master: https://github.com/rails/rails/commit/fbb79b517f3127ba620fedd01849f9628b78d6ce This change provides correct behavior. Unfortunately tests were introduced in https://github.com/rails/rails/commit/971d5107cd4cd08c22a85d34546f4ba03ed5c925 that were relying on the incorrect behavior. We can avoid the fix by changing to another database url such as `mysql` or `postgresql` In addition to fixing the failure, the assertions are changed so that the "expected" value comes before "actual" value.
* Add a changelog entry for #13326 [ci skip]Robin Dupret2013-12-211-0/+8
|
* `html` and `text` templates for mailers by defaultKassio Borges2013-12-207-8/+39
|
* Bump Jbuilder version to 2.0.0Pavel Pravosud2013-12-201-1/+1
|
* Merge pull request #13415 from schneems/schneems/database-no-usernameYves Senn2013-12-192-4/+18
|\ | | | | Do not expect database user with app name to exist
| * Do not expect database user with app name to existschneems2013-12-192-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default when creating a project with `--database=postgresql` the `config/database.yml` file that is generated has a user specified that is the same as the app name ``` development: adapter: postgresql encoding: unicode database: <%= app_name %>_development pool: 5 username: <%= app_name %> password: ``` This is counterintuitive and would rarely be valid. By default postgres creates a user with the current user name (http://www.postgresql.org/docs/9.3/static/database-roles.html) "it will have the same name as the operating system user that initialized the database cluster": ``` $ whoami schneems ``` If the `username` is left out postgresql will assume that you wish to log in as the default user ``` $ psql -c '\du' List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- schneems | Superuser, Create role, Create DB, Replication | {} ``` A good sensible default then for auto generated `database.yml` files is to remove the `username`, and have postgres attempt to connect to the database as the currently logged in user. Instead of submitting with a blank password, don't submit a password.
* | Use sass-rails 4.0.1Takayuki Matsubara2013-12-201-1/+1
| |
* | Merge pull request #13326 from schneems/schneems/add-asset-flagGuillermo Iguaran2013-12-191-0/+5
|\ \ | | | | | | Flag `config.assets.raise_runtime_errors` in dev
| * | Flag `config.assets.raise_runtime_errors` in devschneems2013-12-191-0/+5
| | | | | | | | | | | | | | | By default `config.assets.raise_runtime_errors` should be set to `true` in development for new apps. Source: https://github.com/rails/sprockets-rails/pull/100
* | | Make `rails runner` command options more obviousschneems2013-12-191-5/+14
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're surrounding the options in angle brackets `<>` as is convention in `curl`: ``` $ curl --help Usage: curl [options...] <url> ``` And then in square brackets `[]` with bars `|` as in `tar`: ``` $ tar --help ... Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ] ``` To further clarify that the command can be used with both, we now show examples: ``` Examples: rails runner 'puts Rails.env' This runs the code `puts Rails.env` after loading the app rails runner path/to/filename.rb This runs the Ruby file located at `path/to/filename.rb` after loading the app ``` This format was taken from the `find` man pages: ``` EXAMPLES The following examples are shown as given to the shell: find / \! -name "*.c" -print Print out a list of all the files whose names do not end in .c. find / -newer ttt -user wnj -print Print out a list of all the files owned by user ``wnj'' that are newer than the file ttt. ``` The the text at the bottom is also shifted to improve readability.
* | Make possible to use symbol as the verifier nameRafael Mendonça França2013-12-193-10/+10
| |
* | Change the message verifier argument to verifier_nameRafael Mendonça França2013-12-192-8/+8
| |