Commit Graph

10051 Commits

Author SHA1 Message Date
Rafael Mendonça França
871af9122b Merge pull request #16046 from grosser/grosser/cleangen
Do not load rails without loading bundler
2014-07-04 12:35:46 -03:00
Arun Agrawal
e197fd7f37 Display notice in index.html pages in scaffolded generated views
As we are setting notice in destroy action we should display that

For more information see https://github.com/rails/rails/pull/14044
And https://github.com/rails/jbuilder/pull/191

closes #14044
2014-07-04 16:20:53 +02:00
grosser
8572fcd9f8 remove bundler magic 2014-07-03 17:28:55 -07:00
Rafael Mendonça França
5c87b5c524 Revert "Merge pull request #15394 from morgoth/fix-automatic-maintaining-test-schema-for-sql-format"
This reverts commit 46139d33c06715e74ad450428ece3ee84da98579, reversing
changes made to 8f247871bb18b2e3036a05df5f62cbfe3b402586.

Conflicts:
	activerecord/CHANGELOG.md
2014-07-02 09:41:52 -03:00
Rafael Mendonça França
72f58b0244 Rename preview_enabled option to show_previews 2014-07-01 13:09:24 -03:00
Leonard Garvey
84ed7b8dfe Add configuration to enable mail previews
Adds `config.action_mailer.preview_enabled`

This allows mail previewing to be enabled easily in non-development
environments such as staging. The default is set to true for development
so no changes should be required to existing Rails applications.

The mail preview path can still be configured using the existing
`config.action_mailer.preview_path` configuration option.

Adding this avoids devs from having to do stuff like:
https://gist.github.com/lengarvey/fa2c9bd6cdbeba96526a

Update actionmailer/CHANGELOG with new configuration.
Update configuring guide with new configuratation.
Add `config.action_mailer.preview_path` to configuring guide.
2014-07-01 14:39:59 +10:00
Rafael Mendonça França
ebdedaec32 Merge pull request #15933 from rafael/master
Add always permitted parameters as a configurable option.

[Rafael Mendonça França + Gary S. Weaver]
2014-06-27 18:16:52 -03:00
Rafael Chacón
58399e1dc3 Improvements per code review.
* General style fixes.
* Add changes to configuration guide.
* Add missing tests.
2014-06-27 13:08:40 -07:00
Rafael Mendonça França
30b56084fb Talk about config.assts.version move too
Closes #15942
2014-06-27 16:00:00 -03:00
Viktar Basharymau
0813607c70 Add a test for db:migrate:status to check missing file scenario 2014-06-27 18:28:12 +03:00
Rafael Chacón
c197a7dc41 Add always_permitted_parameters as an option.
* This commit adds back the always_permitted_parameters
  configuration option to strong paramaters.
* The initial pull requests where this feature was added
  are the following:
  - https://github.com/rails/rails/pull/12682
  - https://github.com/rails/strong_parameters/pull/174
2014-06-26 23:01:30 -07:00
Rafael Mendonça França
d625af297a Require shellwords since it is dependecy of this file
Closes #15919
2014-06-26 06:55:18 -03:00
Rafael Mendonça França
5ee87777af Merge pull request #15885 from lucasmazza/lm-skip-routes
Add a '--skip-routes' flag for the Controller generator.
2014-06-24 14:12:44 -03:00
Lucas Mazza
4b173b8ed9 Add a '--skip-routes' flag for the Controller generator.
This way it is possible to skip the addition of the 'get "foo/bar"' routes when
generating a controller.
2014-06-24 14:06:03 -03:00
Yves Senn
9ac1ce11ad :nodoc: all does not remove the constants from the API. [ci skip]
Need to add individual `:nodoc:` for nested classes / modules to completely
remove the constants from the API.
2014-06-24 14:16:29 +02:00
Amit Suryavanshi
de7c61b072 Titling the model name in views generated by scaffold.
eg. rails g scaffold UserProfile will have in index.html.erb "Listing User Profiles"
rather than Listing user_profiles.
2014-06-18 11:32:02 +05:30
Rafael Mendonça França
84a13e019e Deprecate Rails::Rack::LogTailer
It was being used by Rails for show the development logs but since Rails
4 it is not being used anymore on the framework.

This class seems to be private but it were part of the public API we are
deprecating before removing.
2014-06-17 22:48:28 -03:00
Rafael Mendonça França
7f7e2f12ab initialize the right variable 2014-06-17 20:39:49 -03:00
Rafael Mendonça França
8de4d61dc2 ✂️ 2014-06-17 20:35:10 -03:00
Rafael Mendonça França
1056589580 Add a generic --skip-gems options to generator
Also remove --skip-turbolinks.

This option is useful if users want to remove some gems like jbuilder,
turbolinks, coffee-rails, etc that don't have specific options on the
generator.

    rails new my_app --skip-gems turbolinks coffee-rails
2014-06-17 20:35:09 -03:00
Rafael Mendonça França
0724706b6d Merge pull request #15716 from schuetzm/skip-turbolinks
Add an option to skip installation of Turbolinks
2014-06-17 19:47:25 -03:00
Yves Senn
f59ed560ac allow preview interceptors to be registered through config.action_mailer.
This was partially broken because `preview_interceptors=` just assigned the
raw values, whithout going through `register_preview_interceptor`. Now the
Action Mailer railtie takes care of the `preview_interceptors` option.

This commit is a partial revert of:

Revert "Merge pull request #15739 from y-yagi/correct_doc_for_action_mailer_base"

This reverts commit a15704d7f35f17d34d0118546799141d6f853656, reversing
changes made to 1bd12a8609d275ad75fcc4b622ca4f5b32dc76be.

/cc @kuldeepaggarwal @y-yagi
2014-06-15 14:17:00 +02:00
Aditya Kapoor
1505f8b692 [ci-skip] correct wikipedia MVC link 2014-06-14 23:34:08 +05:30
Marc Schütz
e3dca3acc6 Add an option to skip installation of Turbolinks 2014-06-14 12:03:09 +02:00
Yves Senn
46139d33c0 Merge pull request #15394 from morgoth/fix-automatic-maintaining-test-schema-for-sql-format
ActiveRecord::Migration.maintain_test_schema! doesn't work with structure.sql

Conflicts:
	activerecord/CHANGELOG.md
2014-06-12 15:29:20 +02:00
Wojciech Wnętrzak
ad42aaed04 Fixed automatic maintaining test schema to properly handle sql structure schema format.
Additionally:
* It changes `purge` task on `sqlite3` adapter to recreate database file, to
be consistent with other adapters.
* Adds `purge` step when loading from `schema.rb`
2014-06-12 13:08:56 +02:00
Fabian Rodriguez
f374720402 remove unnused method from test 2014-06-11 20:26:47 -03:00
Akshay Vishnoi
b6760d8f14 [ci skip] Fix capitalization 2014-06-07 14:23:27 +05:30
Gaurav Sharma
19ef270923 remove rubyforge.org that was shut down [ci skip] 2014-06-06 22:26:56 +05:30
schneems
72f45ba292 Emit suggested generator names when not found
When someone types in a generator command it currently outputs all generators. Instead we can attempt to find a subtle mis-spelling by running all generator names through a levenshtein_distance algorithm provided by rubygems. 

So now a failure looks like this:

```ruby
$ rails generate migratioooons
Could not find generator 'migratioooons'. Maybe you meant 'migration' or 'integration_test' or 'generator'
Run `rails generate --help` for more options.
```

If the suggestions are bad we leave the user with the hint to run `rails generate --help` to see all commands.
2014-06-04 16:28:43 -05:00
David Jones
1da201b4db File.exist? instead of File.exists? in bin/setup
File.exists? is deprecated in Ruby 2.1+

https://github.com/ruby/ruby/blob/v2_1_2/file.c#L1413
2014-06-02 15:31:09 -04:00
Zachary Scott
4c66ab2b21 Feature requests should be made on the mailing list, not submitted to
the issue tracker. See also #15455 [ci skip]
2014-06-01 19:11:39 -07:00
Yves Senn
75f75a8719 Merge pull request #14881 from robin850/patch-19
Swallow bundler exceptions when running tests
2014-06-01 18:23:10 +02:00
Wojciech Wnętrzak
df6dc1b51a Added missing test case for migrations when using sql structure 2014-06-01 17:30:05 +02:00
Vijay Dev
4ae90a7dd8 Merge branch 'master' of github.com:rails/docrails 2014-06-01 11:46:37 +00:00
Yves Senn
41f4cc0bc6 bin/setup uses bundle check || bundle install to improve performance. 2014-05-30 15:23:26 +02:00
Yves Senn
7ba6b75910 bin/setup script to bootstrap applications. 2014-05-30 11:15:56 +02:00
schneems
1913f1ef90 document generators hidden_namespaces 2014-05-29 14:40:02 -05:00
Yves Senn
99873ca1ea Revert "Merge pull request #12778 from etehtsea/rake-default-fix"
This reverts commit ec0a2b57f67c9153cb5f7bbe2a3f66d13fe64bdd, reversing
changes made to a8bd7b16260c217290ef8fe3a166fcceac442c62.

This reverts commit 555ec36522011862c03b483c53be32410594a51e

This reverts commit 555ec36522011862c03b483c53be32410594a51e

By default, Rails uses the `default` Rake task to run all tests.
This commit changed the environment of the default task to `development`.
This clears the development database and has other negative consequences.
2014-05-28 17:43:45 +02:00
Rafael Mendonça França
be4b3df8bb Merge pull request #15269 from arunagw/aa-fixes-8930
rake railties:install:migrations respects the order of railties
2014-05-27 19:27:40 -03:00
Rafael Mendonça França
6c5f43bab8 Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e04838f01f5589fa50b0baa480d60c815e2c
2014-05-27 19:10:14 -03:00
Arun Agrawal
50de394cc8 rake railties:install:migrations respects the order of railties
This PR fixes #8930 and some stuff from #8985
2014-05-27 16:12:36 +02:00
Yves Senn
83cb356093 Merge pull request #15327 from alexbel/replace_double_quotes_with_single_quotes
Replace double quotes with single quotes while adding an entry into Gemfile
2014-05-27 09:27:36 +02:00
alexbel
6aaf4bff18 Replace double quotes with single quotes while adding an entry into Gemfile 2014-05-26 19:08:03 -04:00
Rafael Mendonça França
6ed161e3fd Merge pull request #15333 from ShunsukeAida/update_ruby_version
update the recommended ruby version.
2014-05-26 15:14:45 -03:00
Rafael Mendonça França
70d126779e Merge pull request #15294 from schneems/schneems/generator-output-in-error2
print generators on failed generate
2014-05-26 14:51:15 -03:00
ShunsukeAida
ad7de78df9 update the recommended ruby version 2014-05-27 02:45:23 +09:00
schneems
e83ce84ef9 print generators on failed generate
Let's say we just ran:

```
$ rails g migrate add_click_to_issue_assignment
```

We will get an error that looks like:

```
Could not find generator migrate.
```

This patch adds all existing migrations to the output to make it easier for a developer to find a valid migration.

```
Could not find generator "migrate". Please select a valid generator:
Rails:
  assets
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  resource
  scaffold
  scaffold_controller
  task
```


It would be nice to do some spelling detection and suggest alternatives, but for now this should  help.
2014-05-26 10:11:07 -05:00
Andriy Tyurnikov
272f80dc16 simple solution that brings rake stats task to every kind of rails project 2014-05-26 02:19:53 +03:00
Guillermo Iguaran
f632f79b8d Merge pull request #15305 from tgxworld/remove_unnecessary_require
Remove unnecessary require of Minitest.
2014-05-24 23:08:29 -05:00
Guo Xiang Tan
4ca5a5ea67 Remove unnecessary require of Minitest.
Minitest has already been required when calling Minitest.autorun.
2014-05-24 20:36:05 -07:00
Xavier Noria
36e3ca6cc5 integration tests do not need to load fixtures by hand
I don't know when this changed, checked back up to 3.2 and integration
tests instantiate fixtures just fine.
2014-05-25 00:45:20 +02:00
Rafael Mendonça França
a9ced732ad Merge pull request #15299 from andriytyurnikov/engine_friendly_rake_stats
rake stats for engines
2014-05-24 15:15:53 -03:00
Andriy Tyurnikov
b71f5f4f55 rake stats for engines 2014-05-24 20:48:24 +03:00
Rafael Mendonça França
e2bd0eb758 Merge pull request #15298 from ShunsukeAida/fix_capitalization
fixed capitalization [ci skip]
2014-05-24 13:42:19 -03:00
Rafael Mendonça França
848776c3da Add FIXME note about the thor bug 2014-05-24 13:34:16 -03:00
ShunsukeAida
b2ec147613 fixed capitalization 2014-05-25 01:33:40 +09:00
Rafael Mendonça França
fd552e597c Merge pull request #9083 from bronson/patch-1
avoid using alias in generators
2014-05-24 13:30:51 -03:00
Yves Senn
ec88d6861a Revert "Merge pull request #15293 from schneems/schneems/generator-output-in-error"
This reverts commit 7466d6a9f989a1a8f90899b79b34f1152e440b7c, reversing
changes made to b850c4c540e8f0c15742f67c532f521a4a123655.

This was an accidental merge. A new PR will follow.

/cc @schneems
2014-05-24 14:22:40 +02:00
Richard Schneeman
7466d6a9f9 Merge pull request #15293 from schneems/schneems/generator-output-in-error
print generators on failed generate
2014-05-24 14:19:17 +02:00
schneems
3915c45980 print generators on failed generate
Let's say we just ran:

```
$ rails g migrate add_click_to_issue_assignment
```

We will get an error that looks like: 

```
Could not find generator migrate.
```

This patch adds all existing migrations to the output to make it easier for a developer to find a valid migration. 

```
Could not find generator "migrate". Please select a valid generator:
Rails:
  assets
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  resource
  scaffold
  scaffold_controller
  task
```


It would be nice to do some spelling detection and suggest alternatives, but for now this should  help.
2014-05-24 14:11:08 +02:00
Zachary Scott
1d7b3fa84c Future port c8ddb61 2014-05-23 14:45:21 -07:00
Jarmo Isotalo
adffea62b5 Upgraded rack
As Rack has some non backwards compatible changes added required
modifications to keep behaviour in rails close to same as before.

Also modified generators to include rack/rack for not yet released
version of rack
2014-05-19 00:03:08 +03:00
Dan Kang
f369bcf9a0 Default config.assets.digests to true in development 2014-05-17 23:01:22 -04:00
Rafael Mendonça França
31fb1ef536 New applications should be created with json serializer
The fix introduced at 75ba7425f6d235f254c00a45a58f42e88f80301a were
missing this case.

To fix the original issue mentioned at that commit the correct is to
remove update_config_files from the command list since we should not run
both config_files command when creating a new application.

Tests were added to make sure everything is working fine.
2014-05-17 15:46:33 -03:00
Christian Wesselhoeft
75ba7425f6 Fix app generator test hanging. 2014-05-17 09:53:44 -07:00
Rafael Mendonça França
ec43d954c5 foo 💣 2014-05-16 20:38:27 -03:00
Rafael Mendonça França
8941d5a36f Generate the cookies_serializer configuration with :marshal when upgrading
We were generating this configuration with :json what may break
applications upgrating from Rails 4.0-.

Now we always generate with a safer value and people is free to choose
hybrid if they want.

We don't generate with hybrid by default because there are some cases
that can fail. These cases are explained on the upgrading guide.
2014-05-16 20:34:06 -03:00
Rafael Mendonça França
890a189bb4 Ok. Enough models for today 😡 2014-05-12 21:28:39 -03:00
Rafael Mendonça França
392e627b12 This is also a model 2014-05-12 21:03:58 -03:00
Rafael Mendonça França
be6ff39199 This model is a model so it should behaves like one 2014-05-12 20:54:06 -03:00
Marcio Junior
bad291eb08 Replace :base with :in [ci skip] 2014-05-11 15:42:35 -03:00
Josemar Luedke
08b435e1bd Change Gemfile’s double quotes in plugin generator
Since the generated application’s Gemfile is using single quotation marks, it
seems fair to use it on plugin’s Gemfile as well.
2014-05-10 17:56:16 -03:00
Rafael Mendonça França
5ff7c591d3 Merge pull request #15015 from pothibo/database-configuration
Use Rails::Paths::Path#existent in database_configuration
2014-05-07 19:25:56 -03:00
Pier-Olivier Thibault
d14fab04ff Use Rails::Paths::Path#existent in database_configuration
Database configuration was trying to load the first path that
config.paths['config/database'] was returning even if the path didn't
exist in the filesystem.

Because Rails::Paths::Path has the possibility to return more than 1
path (as an array), database_configuration should filter down the paths
to the existing one and then load the first one.

This would make it possible to move the database.yml file and add the
new path to paths['config/database'] and still load the configurations.
2014-05-07 18:18:00 -04:00
Paul B
d1fa1fc35a Return a non zero code when db has never been setup on status 2014-05-07 18:33:18 -03:00
Vipul A M
b2437050c8 rename str to string to fix overshadowing of variable 2014-05-07 14:32:27 +05:30
Gabriel Gilder and Jim Kingdon
dac5399af0 Fix rails dbconsole for jdbcmysql adapter. 2014-05-05 14:55:48 -07:00
Arun Agrawal
c694c8e25c skip-git should not hit git commands plugin generators 2014-05-02 15:38:58 +02:00
Roman Shmatov
e8c310edf6 Works correctly if git not installed 2014-05-02 15:38:56 +02:00
Abd ar-Rahman Hamidi
65b551466b Automaticly add username and email if configured in git-scm, as bundle gem 2014-05-02 15:38:07 +02:00
Giovanni Cappellotto
bed8882372 Avoid unnecessary conditional block
GeneratedAttribute#column_name checks already for reference? on the
attribute returning the right name to use as symbol for label and field.
2014-05-01 17:21:16 +02:00
Robin Dupret
48b3257582 Swallow bundler exceptions when running tests
Let's avoid useless output when testing stuff related to Bundler.
2014-04-27 18:25:16 +02:00
Yves Senn
fb1b695f96 Generators, remove leftover variable assignment. refs #14877
The last uses of this variable was removed with the `--builder` option.
  2da5ea1c9feb4a7b491bd00bd6ffd931b9203da8
2014-04-27 10:47:33 -05:00
Aaron Patterson
ccdeb43d2e Merge branch 'master' into adequaterecord
* master: (28 commits)
  move AR length validation tests into separate test-case.
  No need for trailing slash on migration path.
  reset `@arel` when modifying a Relation in place.
  PostgreSQL Timestamps always map to `:datetime`.
  [ci skip] Improve formatting and yml
  Fix a typo in the doc of forty_two AR FinderMethod
  Improve readability of contributing to rails guide. [ci skip]
  Precompile the image we're referencing, too.
  `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
  Fixed an issue with migrating legacy json cookies.
  Correct comment [ci skip]
  Perfer to define methods instead of calling test
  Fix syntax error
  Add CHANGELOG entry for #14757 [ci skip]
  Fix run-on sentences and improve grammar [skip ci]
  Add test for using ActionView::Helpers::FormHelper.label with block and html
  select! renamed to avoid name collision Array#select!
  Rearrange deck chairs on the titanic. Organize connection handling test cases.
  Change favicon_link_tag helper mimetype from image/vnd.microsoft.icon to image/x-icon.
  ActionController::Renderers documentation fix
  ...
2014-04-25 12:37:08 -05:00
Matthew Draper
4f31b7767e Precompile the image we're referencing, too.
You can't compile a file that references a non-compiled asset's path.

.. unless you turn off asset runtime errors.

Outside of a test case like this, `config.assets.precompile` would
normally retain its default entry, which precompiles all images (and
other non-JS/CSS files) that are in `app/assets`.
2014-04-24 04:49:02 +09:30
Aaron Patterson
b395265f7c Revert "Edge Rails applications doesn't need to use arel master"
This reverts commit 7f62f30f58fe5f2955e3292ab1f01aa2c9a8f0ee.
2014-04-23 08:55:38 -05:00
Rafael Mendonça França
43f525031a Make console and generators blocks works at Application instance level
Like rake tasks and runner blocks these blocks should also being shared
between applications since they are stored at the classes.

Fixes #14748
2014-04-14 18:59:47 -03:00
Rafael Mendonça França
e8c66288d6 ✂️ 2014-04-14 18:51:34 -03:00
Phil Ross
c8ccab0527 Bundle tzinfo-data on :x64_mingw (64-bit Ruby on Windows). 2014-04-12 18:44:50 +01:00
Rafael Mendonça França
7bb8fd2f64 Merge pull request #14646 from deivid-rodriguez/provide_byebug_by_default
Improve debugging support
2014-04-11 13:55:10 -03:00
Rafael Mendonça França
f166f1da46 Merge pull request #14689 from matthewd/asset_initializer
Move assets precompile (and version) to an initializer
2014-04-11 12:56:03 -03:00
Matthew Draper
f612c2b052 Move assets precompile (and version) to an initializer
sprockets-rails 2.1 needs the precompile list to be available in all
environments.
2014-04-11 22:47:54 +09:30
Rafael Mendonça França
53610e5140 Require action_controller before any other action_controller file
This will load properly the loading hooks.

Closes rails/sass-rails#205
2014-04-10 15:00:03 -03:00
David Rodríguez de Dios
7fe49a4545 Prevent generation of extra whitespace in templates 2014-04-10 16:20:46 +02:00
David Rodríguez de Dios
6fae9ac581 Isolate debugger related code 2014-04-10 16:02:13 +02:00
Akira Matsuda
bb63e9c590 +EOL 2014-04-10 15:44:38 +09:00
Rafael Mendonça França
b053a47b3e depend_on_asset is not required anymore on sprockets-rails 2.1.2 2014-04-09 14:07:31 -03:00
David Heinemeier Hansson
304d2f19c8 Dont abbreviate that which needs no abbreviation 2014-04-08 21:12:36 +02:00
David Heinemeier Hansson
10570cfd5b Dont encourage aliases now that we have variants 2014-04-08 21:12:36 +02:00
David Heinemeier Hansson
4b0c8a9467 Use short-form for the scaffold render calls and drop the needless test 2014-04-08 20:57:24 +02:00
David Rodríguez de Dios
d8a4e48220 Update Gemfile templates to provide correct debugger 2014-04-08 20:57:12 +02:00
David Rodríguez de Dios
7901ae13a1 Keep debugger support only for rubies < 2.0.0 2014-04-08 20:55:23 +02:00
Matthew Draper
d72a0cbc80 Drop in @jeremy's new database.yml template text
In passing, allow multi-word adapters to be referenced in a URL:
underscored_name must become hyphened-name.
2014-04-09 01:46:48 +09:30
Rafael Mendonça França
e1404ec824 Rails.application should be set inside before_configuration hook
Fixes #14620
2014-04-07 17:35:00 -03:00
Carlos Antonio da Silva
70c83f49f8 Remove useless begin..end 2014-04-07 16:53:58 -03:00
Rafael Mendonça França
bc6a949020 Declare the assets dependency 2014-04-04 18:03:14 -03:00
Rafael Mendonça França
61a8fd5e1b Use sass-rails 4.0.3 2014-04-04 18:03:00 -03:00
Matthew Draper
b058897da8 Ensure we supply Kernel#y for 1.9 too
In 1.9, it doesn't live in its own file, so we'll have to define it
ourselves.

Check RUBY_VERSION, instead of rescuing the require, because we want
this to break if `psych/y` moves in a future Ruby release.
2014-04-04 22:48:38 +10:30
Matthew Draper
272f7c29e2 Explicitly load Kernel#y when starting a console
Previously, we relied on the IRB-detection in Psych itself. But that
doesn't work when we're running under spring: the application boots (and
thus psych is required) before we switch to console mode and load IRB.

Fixes #14587.
2014-04-04 04:29:50 +10:30
Matthew Draper
f846828dae Revise 'sqlite3:' URL handling for smoother upgrades
Restore the 4.0 behaviour for 'sqlite3:///', but deprecate it. We'll
change to the absolute-path interpretation in 4.2.

The current "correct" spellings for in-memory, relative, and absolute
URLs, respectively, are:

    sqlite3::memory:
    sqlite3:relative/path
    sqlite3:/full/path

Substantially reverses/defers fbb79b517f3127ba620fedd01849f9628b78d6ce.
Uncovered by @guilleiguaran while investigating #14495, though that
sounds like a different issue.
2014-04-03 01:30:27 +10:30
Adrià Planas
7afe193887 Require yaml explicitly 2014-03-29 21:21:01 +01:00
Rafael Mendonça França
555ec36522 Add CHANGELOG entry for #12778 [ci skip] 2014-03-28 12:28:28 -03:00
Rafael Mendonça França
ec0a2b57f6 Merge pull request #12778 from etehtsea/rake-default-fix
Don't load test env by default.

Closes #13241
2014-03-28 10:24:18 -05:00
Rafael Mendonça França
8a081db357 Fix build with bundler 1.6 2014-03-26 22:19:29 -03:00
Rafael Mendonça França
7f62f30f58 Edge Rails applications doesn't need to use arel master 2014-03-26 22:18:53 -03:00
Kuldeep Aggarwal
5a3817cb16 Fix Generation of proper migration when
ActiveRecord::Base.pluralize_table_names = false.

  Previously, generation a migration like this:

      rails g migration add_column_name_to_user name

  would not generating the correct table name.

Fixes #13426.
2014-03-25 20:27:37 +05:30
Rafael Mendonça França
b9440c36dd Check if any sqlite files are not included in the gitignore
If the sqlite file name change in future version we this regexp should
catch
2014-03-24 09:24:47 -03:00
Rafael Mendonça França
9d8354c9d3 Merge pull request #14447 from Houdini/gitignore
Skip sqlite3 files in .gitignore if no sqlite3 in app
2014-03-24 09:22:11 -03:00
Dmitrii Golub
f42c7eee7e Remove sqlite3 lines from .gitignore if the application is not using sqlite3. 2014-03-24 14:53:38 +04:00
Ankit Gupta
23eafe8877 Adding active_model in Rails::Info 2014-03-23 23:55:03 -04:00
Yves Senn
582cbff616 test for structure:dump without schema information table. refs eafec46
This is a test case for the fix provided in eafec4694c5b37eff9d83b1188b8e331fa6027fa
2014-03-20 18:40:51 +01:00
Carlos Antonio da Silva
97229c69ea Remove some indirection in rake dbs test
Just pass in the expected database as argument rather than "caching"
it in a hash and using the hash in the helper methods.
2014-03-20 08:27:23 -03:00
Carlos Antonio da Silva
66dc576217 Check if the output is empty rather than asserting for equality
Also fix indent of test block.
2014-03-20 08:19:33 -03:00
Carlos Antonio da Silva
e0235c3721 Refactor assertion of line numbers matching 4 spaces 2014-03-19 21:47:38 -03:00
Carlos Antonio da Silva
29aff93dc4 Move booting/loading tasks setup to the rake notes helper method 2014-03-19 21:47:38 -03:00
Carlos Antonio da Silva
9c5c0bcfa6 Extract rake notes command and lines scan boilerplate
Refactor to a reusable method.
2014-03-19 21:47:38 -03:00
Carlos Antonio da Silva
3a3a386d4f Remove extra space assertion
No need to check that each line contains an extra space, just matching
the space in the regexp is enough to ensure that.
2014-03-19 21:47:38 -03:00
Carlos Antonio da Silva
dcf7a166f2 Extract common setup for loading tasks in rake notes tests 2014-03-19 21:47:38 -03:00
Guillermo Iguaran
4a69c933cf Merge pull request #14379 from robertomiranda/rake-notes.config
Add Public Api for Register New Extensions for Rake Notes
2014-03-17 17:47:24 -05:00
robertomiranda
3b073ac195 Rake notes should picked up new Extensions registered in the config/application.rb file 2014-03-17 17:03:52 -05:00
robertomiranda
8eac0a6b58 Add Changelog Entry ref #14379 2014-03-17 09:06:00 -05:00
Carlos Antonio da Silva
1330274657 Fix assertions 2014-03-16 22:47:35 -03:00
robertomiranda
27e95727d7 Add config.annotations, in order to register new extensions for Rake notes at config level 2014-03-16 14:57:21 -05:00
robertomiranda
ce38a6b8b6 Fix Shadowing extensions variable in Register Annotation Exentsions 2014-03-16 14:32:08 -05:00
Akira Matsuda
e9625d63bb Let COMMAND_WHITELIST be an Array, not a String 2014-03-16 12:23:58 +09:00
robertomiranda
f43421cb65 Supporting .ruby, .yml and .yaml Extension in Rake Notes 2014-03-14 17:51:14 -05:00
robertomiranda
810af6f6ee Remove .scss, .sass, .less, .haml, .slim, coffee from Rake Notes. Now we have an API for register it in the corresponding gems 2014-03-14 17:39:04 -05:00
robertomiranda
a2fb164a4f Add Public Api for register new extensions for Rake Notes 2014-03-14 15:22:02 -05:00
schneems
aa27766e2f better test error messages 2014-03-14 11:40:14 -05:00
Rafael Mendonça França
eaa19cc576 Force sass-rails ~> 4.0.2 to avoid sprockets compatibility error
See https://github.com/rails/sass-rails/issues/191 for more information
2014-03-14 13:20:16 -03:00
Aaron Patterson
499c6aa684 require actions rather than create_file
thor's create_file seems to have a circular dependency on itself when
used with our constant loading stuff.

fixes #14319
2014-03-13 12:02:32 -07:00
Arun Agrawal
9e61a14d4b Removed unnecessary command "application" 2014-03-10 23:23:12 +01:00
Andrew White
ec23277124 Merge pull request #14262 from sferik/flat_map
Replace additional instances of map.flatten with flat_map
2014-03-09 10:04:57 +00:00
Robin Dupret
9c53b8b89f Make the rails:template rake task load initializers
Templates could rely on irregular inflections or external libraries for
instance so we should load the application's initializers when running
the rails:template task.

The introducing commit of this feature is f7f11361 ; the initializers
have never been loaded invoking this task.

Fixes #12133.
2014-03-08 15:59:22 +01:00
Prem Sichanugrist
2dd2fcf896
Introduce Rails.gem_version
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05:00
Erik Michaels-Ober
cff340f1ed Replace map.flatten with flat_map in railties 2014-03-04 09:13:44 -08:00
Carlos Antonio da Silva
ab1bd7ccf1 Always return an array from formats so there is no need to wrap it when calling 2014-03-04 11:26:09 -03:00
Allen Fair
3624ff720c Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke
filename_with_extensions with the old signature (without format).
This makes the second argument optional and defaults it to the #format
method which could be overridden as well.

Closes #14132.
2014-03-04 11:25:52 -03:00
Guillermo Iguaran
b0767afac5 Merge pull request #14195 from robin850/issue-14079
Avoid namespacing routes inside engines
2014-02-28 19:26:04 -05:00
Yves Senn
14e697cf2a Merge pull request #14174 from kuldeepaggarwal/fix-resource_generator_test
fix test cases
2014-02-27 18:57:45 +01:00
Kuldeep Aggarwal
adff19cc3b modify model generator warning message. refs [#174c9f0] 2014-02-27 22:04:01 +05:30
Aaron Patterson
59ec4562a2 pass strings to the underscore method 2014-02-26 15:43:20 -08:00
Robin Dupret
fc61bca31d Avoid namespacing routes inside engines
Since #11544, invoking the controller generator, any generated route is
namespaced according to the class_path method. Since a mountable plugin
is namespaced, creating a controller inside would generate a namespaced
route based on the engine's name.

The controller generator now relies on regular_class_path which does not
contain the class hierarchy but the given path.

Fixes #14079.
2014-02-26 16:06:11 +01:00
Carlos Antonio da Silva
89b4b51fdc Merge pull request #14149 from tjschuck/bcrypt_gem_rename
Bump version of bcrypt gem
2014-02-26 08:11:50 -03:00
Carlos Antonio da Silva
1d298bd621 Remove inclusion of rubysl gem for rbx on generated Gemfile
From #14026:

    Specific rbx-2 to limit testing on Rubinius 2.x (since there will be
    other versions of Rubinius > 2.x soon).

    Also, as of Rubinius 2.2.5, it is no longer necessary to bundle the
    rubysl gem.

This is what Rails master/4.1 supports, so we don't need to add rubysl to
gemfiles anymore.
2014-02-25 21:54:29 -03:00
Spencer Rogers
ad75539a0c [skip ci] Fix test name typo in app generator tests. 2014-02-25 17:25:41 -05:00
T.J. Schuck
53f1ab523b Bump version of bcrypt gem 2014-02-25 09:52:32 -05:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
Yves Senn
b5c6c31dba build fix. follow up to 174c9f0df39cd338a4871f82794256cc64f68a81 2014-02-24 10:09:56 +01:00
Yves Senn
174c9f0df3 include names in model generator warning message. refs #13515.
This is a follow up to #13515. It includes the name given and
the singularized version in the warning message. This will aide the user
to see wether the detected singular was right or not.
2014-02-24 09:45:24 +01:00
Carlos Antonio da Silva
2403869966 Group assets options in production env template 2014-02-23 22:45:16 -03:00
Yves Senn
c554d170e6 update version to 4.2.0.alpha 2014-02-23 13:14:43 +01:00
Godfrey Chan
f8dcc48517 Merge pull request #13515 from kuldeepaggarwal/f-model-generation
Added warning when user tried to create model with pluralize name.
2014-02-22 23:44:08 -08:00
Kuldeep Aggarwal
de8bef9878 Add warning when user tried to create model with pluralize name.
1. Generate model with correct_name.
  2. It will help new users to avoid mistakes when tried to create model with wrong name.
2014-02-23 13:10:41 +05:30
Guillermo Iguaran
b1867c85fa Revert "Only lookup config.log_level for stdlib ::Logger. Closes #11665."
This reverts commit e0a521cfcd13e4d1f0ae8ab96004289e1c020f71.

Conflicts:
	railties/CHANGELOG.md

We expect loggers to quack like stdlib logger. If log4r needs different
level= assignment, using a Logger-quacking wrapper is the way to do it.

Fixes #14114.
2014-02-21 09:50:19 -05:00
Rafael Mendonça França
1879c259b8 Merge branch '4-1-0-beta2'
Conflicts:
	actionview/CHANGELOG.md
	activerecord/CHANGELOG.md
2014-02-18 16:00:47 -03:00
Rafael Mendonça França
8b20c72dd8 Preparing for 4.1.0.beta2 release 2014-02-18 15:45:20 -03:00
Arun Agrawal
5f07366bed Revert "Fixed plugin_generator test"
This reverts commit fefa8ae9a172835fb6b8aef7d1dd46d58eecd49f.
2014-02-15 11:26:17 +01:00
Aaron Patterson
22a1a5ac8c remove railties changes. fixes #14054
Squashed commit of the following:

commit 96991e8e919edfb20cc4120bca4e36ed51175d57
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:29:24 2014 -0800

    Revert "gems can be added or skipped from the template"

    This reverts commit 8beb42cfbc41753ae4dbb91e16abcd1fb7d00356.

    Conflicts:
    	railties/lib/rails/generators/rails/app/app_generator.rb
    	railties/test/generators/app_generator_test.rb

commit 35599c0e657245ef14ac0f28c9189ad16acf40e6
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:26:53 2014 -0800

    Revert "oops, template replay needs to happen after bundle. :orz:"

    This reverts commit 9104702be61253f9448ca070a22fc86bb4299555.

    Conflicts:
    	railties/lib/rails/generators/rails/app/app_generator.rb

commit f519c3902c313db8e906a49251c91643b8e6499e
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:25:51 2014 -0800

    Revert "only ask for these ivars if the target responds to them"

    This reverts commit 656d412546cd97d5660c634c2a41c799d3f9e211.

commit aa524a9428e3e4c45fe221f10a66a08efb827ab5
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:25:39 2014 -0800

    Revert "refactor generator tests to use block form of Tempfile"

    This reverts commit 65251820ef0ab7f3cffb38130de3dd41af8d72be.

commit 7d3740549fa4dfa62e3761f8d4bc6d6d441256e7
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:25:25 2014 -0800

    Revert "add a more restricted codepath for templates fixes #13390"

    This reverts commit 2875b4a66e38e4333da887a4afbed33358999298.

commit 525df0af1001918986cdfce59539fd2d52c4f32c
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri Feb 14 11:25:11 2014 -0800

    Revert "add a send so `apply` can be called.  Fixes #13510"

    This reverts commit c5034d60dba0cd31a6a8c612ee35d63b8127793a.
2014-02-14 11:38:26 -08:00
Kassio Borges
aae455f636 fix path shown in mailer's templates 2014-02-14 14:17:12 -02:00
Guillermo Iguaran
de5ef15398 Merge pull request #13945 from rails/json_cookie_serializer_improvements
Cookies serializer improvements
2014-02-13 09:41:13 -05:00
Yves Senn
37e30d2548 do not crash when config/secrets.yml is blank. 2014-02-12 17:17:00 +01:00
Christian Wesselhoeft
2c7471a95d Hide bundler output for rails new if quiet option is specified. 2014-02-11 23:12:38 -08:00
Aaron Patterson
c5034d60db add a send so apply can be called. Fixes #13510
THIS IS A HUGE HACK.  Thor does not allow us to define public methods
without turning them in to "thor tasks".  That means we cannot subclass
the `apply` method and make it public, so we have to make the method
private and call `send` on it.
2014-02-11 14:08:12 -08:00
Godfrey Chan
0b86a6e950 Updated CHANGELOG, docs, guides and release notes.
Also added a `cookies_serializer.rb` initializer to the app template.
2014-02-11 02:52:07 -08:00
Guillermo Iguaran
cd5960e976 Fix AppGeneratorTest: serializer option was removed from session_store 2014-02-11 01:54:17 -08:00
Guillermo Iguaran
3a89386fcf Remove serializer option from session_store.rb template 2014-02-11 01:54:17 -08:00
Godfrey Chan
b927d67dec Renamed session_serializer option to cookies_serializer 2014-02-11 01:54:16 -08:00
Xavier Noria
c0fb8d0b9c Merge branch 'dump-schema-after-migration-flag' of git://github.com/emilsoman/rails into emilsoman-dump-schema-after-migration-flag
Conflicts:
	activerecord/CHANGELOG.md
2014-02-06 15:03:20 +01:00
Emil Soman
8806768e9f Add config to disable schema dump after migration
* Add a config on Active Record named `dump_schema_after_migration`
* Schema dump doesn't happen if the config is set to false
* Set default value of the config to true
* Set config in generated production environment file to false
* Update configuration guide
* Update CHANGELOG
2014-02-06 17:38:31 +05:30
Yves Senn
580f0b61dc synchronize 4.1 release notes with CHANGELOGS. [ci skip]
/cc @chancancode
2014-02-06 11:43:16 +01:00
Rafael Mendonça França
32bdbdd16f Merge pull request #13612 from eval/issue-13588
Add CreateMigration action
2014-01-30 11:11:45 -08:00
Guillermo Iguaran
fd487860db Modify the session serializer implementation
Rename allowed options to :marshal and :json, for custom serializers
only allow the use of custom classes.
2014-01-30 01:53:19 -05:00
schneems
7d6592ebd0 Enhance errors while retrieving database config
Right now if there is an error retrieving database configuration the intent of the error (what the code was trying to do while you got the error) could be more explicit. 

Instead of this error:

```
Invalid DATABASE_URL: nil
(erb):9:in `rescue in <main>'
(erb):6:in `<main>'
/Users/schneems/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `eval'
/Users/schneems/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `result'
/Users/schneems/Documents/projects/rails/railties/lib/rails/application/configuration.rb:98:in `database_configuration'
/Users/schneems/Documents/projects/rails/activerecord/lib/active_record/railtie.rb:41:in `block in <class:Railtie>'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `instance_exec'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `each'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/application.rb:339:in `block in run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/engine/railties.rb:13:in `each'
```

I propose we issue this error:

```
Cannot load `Rails.application.database_configuration`:
Invalid DATABASE_URL: nil
(erb):9:in `rescue in <main>'
(erb):6:in `<main>'
/Users/schneems/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `eval'
/Users/schneems/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `result'
/Users/schneems/Documents/projects/rails/railties/lib/rails/application/configuration.rb:98:in `database_configuration'
/Users/schneems/Documents/projects/rails/activerecord/lib/active_record/railtie.rb:41:in `block in <class:Railtie>'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `instance_exec'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `each'
/Users/schneems/Documents/projects/rails/railties/lib/rails/railtie.rb:237:in `run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/application.rb:339:in `block in run_tasks_blocks'
/Users/schneems/Documents/projects/rails/railties/lib/rails/engine/railties.rb:13:in `each'
```
2014-01-29 14:16:39 -06:00
Lukasz Sarnacki
b23ffd0dac Allow session serializer key in config.session_store
MessageEncryptor has :serializer option, where any serializer object can
be passed. This commit make it possible to set this serializer from configuration
level.

There are predefined serializers (:marshal_serializer, :json_serialzier)
and custom serializer can be passed as String, Symbol (camelized and
constantized in ActionDispatch::Session namepspace) or serializer object.

Default :json_serializer was also added to generators to provide secure
defalt.
2014-01-29 17:05:00 +01:00
Carlos Antonio da Silva
61bd71ef5c Merge pull request #13857 from teoljungberg/replace-file-exists-eh
Replace File.exists? with File.exist?
2014-01-27 16:59:32 -08:00
Gert Goet
3858a247bd Add CreateMigration action
This Thor-action isolates the logic whether to (over-)write migration and
what is shown to the user. It's modelled after Thor's CreateFile-action.

This solves the issue that removing a non-existing migration, tried to
remove the template-path (#13588).

Related issues: #12674
2014-01-28 00:01:19 +01:00
Teo Ljungberg
7a372c8429 Replace File.exists? with File.exist?
To quell warnings on ruby 2.1
2014-01-27 22:21:28 +01:00
Kassio Borges
433628a45c Rails config for raise on missing translations
Add a config to setup whether raise exception for missing translation or
not.
2014-01-27 08:03:46 -02:00
Adrien Lamothe
9d0fceb55d Correct grammar from '... allowing both thread web servers ...' to '... allowing both threaded web servers ...'. 2014-01-25 23:04:36 -08:00
Robin Dupret
fe63933cee Add a missing changelog entry for #13825 [ci skip] 2014-01-25 22:12:28 +01:00
Guillermo Iguaran
0a43bf3146 Add a test-case for GH #13825 2014-01-24 14:10:46 -05:00
Byron Bischoff
cf6c00d027 app_rails_loader.rb should check if bin/rails is a File before calling File.read(exe); closes #13825 2014-01-24 10:00:31 -08:00
Yves Senn
c60e06261b Merge pull request #13696 from senny/engine_bin_rails_load_bundler
setup Bundler in engines `bin/rails` stub.
2014-01-21 05:58:01 -08:00
anilmaurya
41722dd444 moving controller_name assignment before model name condition 2014-01-20 16:50:29 -02:00
robertomiranda
7671590fe2 Update Changelog, Spring is under rails/spring [ci skip] 2014-01-19 08:50:15 -05:00
Washington Luiz
e05c791264 spring gem moved to rails/spring 2014-01-18 20:22:51 -03:00
Carlos Antonio da Silva
1c88b363a3 Unify changelog entries about single quotes [ci skip] 2014-01-15 19:26:00 -02:00
Chulki Lee
1ab6c656d6 Use single quotes in generated files 2014-01-14 11:13:42 -08:00
Cristian Mircea Messel
9cdc7c0614 single quotes for controller generated routes
Write routes in route.rb with single quotes

    get 'welcome/index'

instead of

    get "welcome/index"
2014-01-14 09:31:51 +02:00
schneems
b9095ec95c Favor canonical environment variables for secrets
Prefixing an environment variable with `RAILS_` should be used when there is otherwise a conflict, such as `RAILS_ENV` or if it is being used for a very Rails specific value.

If we remove the prefix of `RAILS_` in the case of `RAILS_SECRET_KEY_BASE` then we can push for a pseudo standard among other frameworks that will accept a common environment key `SECRET_KEY_BASE` to keep your app secure. This is beneficial for containerized deployments such as docker, Heroku, etc. So that the container need to know one less thing about your app (it can just set it no-matter what language or framework you are using). 

This change also allows the defaults to be consistent with the way the secret key is accessed so `secrets.secret_key_base` is aliased to `SECRET_KEY_BASE` instead of `RAILS_SECRET_KEY_BASE`.
2014-01-13 14:31:43 -06:00
Yves Senn
e0a521cfcd Only lookup config.log_level for stdlib ::Logger. Closes #11665.
This prevents Rails from assigning meaningless log levels to third
party loggers like log4r. If `Rails.logger` is not `kind_of?(::Logger)`
we simply assign the `config.log_level` as is.

This bug was introduced by #11665.
2014-01-13 19:00:45 +01:00
Yves Senn
755fd79ff3 setup Bundler in engines bin/rails stub.
This is necessary when bundling gems locally using `BUNDLE_PATH`.
Without this patch `bin/rails` fails with:

```
/Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rails/all (LoadError)
	from /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from bin/rails:7:in `<main>'
```
2014-01-13 15:42:10 +01:00
Gaurish Sharma
35e56f6fa5 standardize on jruby_skip & rbx_skip
This Adds helpers(jruby_skip & rbx_skip). In Future, Plan is to use
these helpers instead of calls directly to
RUBY_ENGINE/RbConfig/JRUBY_VERSION
2014-01-13 19:51:47 +05:30
Gaurish Sharma
4aca806017 Skip Spring App Generator tests on JRuby
Spring makes extensive use of Process.fork, so won't be able to provide
JRuby Support, hence skip these tests on JRuby.
2014-01-13 02:58:03 +05:30
Xavier Noria
db11682c2b fixes a typo in a CHANGELOG 2014-01-12 22:24:28 +01:00
Xavier Noria
6049249c6c upgrade SDoc
Kudos to @zzak for taking over SDoc and make it work with RDoc 4.
2014-01-12 22:18:44 +01:00
Xavier Noria
20a795f64d fixes the Gemfile generator templates
The templates were written as if for a given gem you could either pass a version
or options, but not both. But you may want to specify a version and also a group
or whether the gem has to be required, for example.
2014-01-12 22:14:44 +01:00
Arun Agrawal
b4f9377b3a Removing without_thor_debug
a1d0c0fa3d8ca97edc8f2a1d6ba96af19221dbad

as bundler 1.5.2 is out now
2014-01-11 08:50:31 +01:00
schneems
6cc03675d3 Ensure Active Record connection consistency
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.
2014-01-09 16:35:37 -06:00
Zachary Scott
7d414eaa9c MySQL version 4.1 was EOL on December 31, 2009
We should at least recommend modern versions of MySQL to users.
2014-01-08 18:38:38 -08:00
Aaron Patterson
2875b4a66e add a more restricted codepath for templates fixes #13390 2014-01-08 15:07:15 -08:00
Rafael Mendonça França
e4e750ba1a Merge pull request #13637 from craftsmen/app-generator-minor-fix
Move finish_template as the last public method defined in the generator
2014-01-08 13:37:12 -08:00
Aaron Patterson
65251820ef refactor generator tests to use block form of Tempfile 2014-01-08 12:05:52 -08:00
Mehdi Lahmam
87628654f0 Move finish_template as the last public method in the generator 2014-01-08 19:51:05 +01:00
Carlos Antonio da Silva
16a27b68ea Fix rdoc markup [ci skip]
Wrapping symbols with + does not work, we must use <tt> instead.
2014-01-06 08:50:33 -02:00
Robin Böning
6cc087b28d Add missing tests for invalid names in rails plugin new
* Test for: Invalid plugin name, because of reserved rails word.
* Test for: Invalid plugin name because of constant name that is already in use.
2014-01-06 11:28:04 +01:00
Andrew White
3713e43366 Add preview_path to autoload_paths in after_initialize
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
2014-01-04 18:42:34 +00:00
T.J. Schuck
72bb3fc297 Change all "can not"s to the correct "cannot". 2014-01-03 17:02:31 -05:00
schneems
f642b18c0e Use DATABASE_URL by default
See https://github.com/rails/rails/pull/13463#issuecomment-31480799 for full conversation.
2014-01-02 15:00:30 -06:00
Jon Leighton
ff7ab3bc78 Automatically maintain test database schema
* 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".
2014-01-02 13:49:00 +00:00
Andrew White
a1d0c0fa3d Reverse 821525e and wrap run_generator call
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`.
2014-01-02 10:06:29 +00:00
Rafael Mendonça França
02d366842c Adding missing require 2014-01-02 00:52:47 -02:00
schneems
9749e0efbf Move default production database to URL sub key
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.
2014-01-01 17:48:24 -05:00
Vipul A M
98cb3e69af update copyright notices to 2014. [ci skip] 2014-01-01 23:59:49 +05:30
Brian Cardarella
9e8592c217 Fix comment syntax
The code syntax in the comment example is invalid
2013-12-31 21:58:04 -05:00
Arun Agrawal
f593b695fe rbconfig is not used in these files
remove unused requires
2013-12-26 21:18:14 +01:00
Chun-wei Kuo
fbbd4e1899 Improve font of some code in API documentation [ci skip]
* Add "<tt>" or "+" to improve font of some code and filenames in API documentation
* Does not contain wording changes
2013-12-26 18:54:46 +08:00
schneems
d0926d3d5e fix 2.1.0 bug :( 2013-12-25 18:27:09 -05:00
schneems
707be603cf ensure environment is run before db:structure:load
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
```
2013-12-25 18:03:55 -05:00
schneems
ba882934bb Partial fix of database url tests
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
2013-12-25 18:03:55 -05:00
Guillermo Iguaran
d80ad96b95 Fix tests names: tokens.yml => secrets.yml 2013-12-25 17:34:25 -05:00
Kuldeep Aggarwal
b9d79b1f5f using symbol instead of string in establish_connection 2013-12-25 15:24:25 +05:30
José Valim
f89c5f46b5 Revert "Ensure secret_key_base is set for all environments"
A better solution has been pushed to master.

This reverts commit 959cfcef7255bba720ce3f15323056533ea7b50a.
2013-12-24 19:29:31 +01:00
José Valim
db22a5a8eb Merge pull request #13472 from schneems/schneems/fix-master-database-url-tests
Fix railties tests in master
2013-12-24 10:20:51 -08:00
José Valim
df09ce966e Merge pull request #13471 from schneems/schneems/better-secrets-error-message
Better missing `secret_key_base` error message
2013-12-24 08:22:30 -08:00
schneems
14c175c572 Fix railties tests in master
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.
2013-12-24 11:13:47 -05:00
schneems
d641a0cf0d Better missing secret_key_base error message
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`
```
2013-12-24 11:08:16 -05:00
José Valim
959cfcef72 Ensure secret_key_base is set for all environments 2013-12-24 16:35:43 +01:00
José Valim
d2ed433b0a Only build a ConnectionSpecification if required 2013-12-24 10:02:07 +01:00
José Valim
d8336cab32 Fix build failures related to the new ENV options in yml 2013-12-24 09:26:34 +01:00
José Valim
2d4cfb2840 Update CHANGELOG [ci skip] 2013-12-23 20:34:11 +01:00
José Valim
f6e363309a Use the new Resolver API in dbconsole 2013-12-23 20:32:44 +01:00
José Valim
facf2b47a4 Add examples and namespace ENV options with "RAILS_" 2013-12-23 20:27:17 +01:00
José Valim
d22a359a18 Do not store production information in .yml files
Instead, read information from environment variables.
2013-12-23 18:54:39 +01:00
Andrew White
cbd4bc84af Add comments with urls for email previews 2013-12-22 10:06:12 +00:00
schneems
dd93a5f459 Use Full path to sqlite database in tests 2013-12-22 00:56:59 -05:00
schneems
a1f9ae5eb8 Fix DB Console tests
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: fbb79b517f

This change provides correct behavior. Unfortunately tests were introduced in 971d5107cd 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.
2013-12-21 23:09:01 -05:00
Robin Dupret
d39db9da1a Add a changelog entry for #13326 [ci skip] 2013-12-21 14:49:16 +01:00