rails 4.1.0.beta2 → 4.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/images/getting_started/challenge.png +0 -0
- data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/assets/images/getting_started/form_with_errors.png +0 -0
- data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/assets/images/getting_started/new_article.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.jpg +0 -0
- data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/assets/images/getting_started/{show_action_for_posts.png → show_action_for_articles.png} +0 -0
- data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/bug_report_templates/action_controller_gem.rb +5 -2
- data/guides/bug_report_templates/active_record_gem.rb +4 -1
- data/guides/code/getting_started/Gemfile +20 -23
- data/guides/code/getting_started/Gemfile.lock +73 -67
- data/guides/code/getting_started/app/views/layouts/application.html.erb +2 -2
- data/guides/code/getting_started/config/environments/production.rb +2 -2
- data/guides/code/getting_started/config/environments/test.rb +1 -1
- data/guides/rails_guides/helpers.rb +2 -0
- data/guides/source/3_0_release_notes.md +1 -1
- data/guides/source/4_1_release_notes.md +181 -61
- data/guides/source/action_controller_overview.md +46 -7
- data/guides/source/action_mailer_basics.md +5 -5
- data/guides/source/active_record_querying.md +18 -18
- data/guides/source/active_record_validations.md +11 -9
- data/guides/source/active_support_core_extensions.md +13 -1
- data/guides/source/api_documentation_guidelines.md +52 -2
- data/guides/source/asset_pipeline.md +54 -22
- data/guides/source/association_basics.md +13 -0
- data/guides/source/configuring.md +159 -11
- data/guides/source/contributing_to_ruby_on_rails.md +7 -6
- data/guides/source/development_dependencies_install.md +2 -0
- data/guides/source/documents.yaml +1 -1
- data/guides/source/engines.md +4 -3
- data/guides/source/form_helpers.md +10 -3
- data/guides/source/getting_started.md +525 -478
- data/guides/source/i18n.md +4 -4
- data/guides/source/initialization.md +2 -2
- data/guides/source/layouts_and_rendering.md +38 -8
- data/guides/source/migrations.md +5 -5
- data/guides/source/plugins.md +0 -1
- data/guides/source/routing.md +4 -2
- data/guides/source/security.md +47 -4
- data/guides/source/testing.md +10 -31
- data/guides/source/upgrading_ruby_on_rails.md +121 -12
- data/guides/source/working_with_javascript_in_rails.md +1 -1
- metadata +23 -24
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
- data/guides/assets/images/getting_started/new_post.png +0 -0
- data/guides/assets/images/getting_started/post_with_comments.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_posts_new.png +0 -0
- data/guides/assets/images/getting_started/undefined_method_post_path.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_posts.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7621750645b2b3623245eeecac73b517d827c5e
|
4
|
+
data.tar.gz: b90a28e976f9af320a80b48f06a28d0e82d507aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63d3210259a8630b1ff4c840753ea77424a8fd7489d687ee5de9fbc5e7f036848a332878110b1a9de7f46f0935595611b14ea34f43db4b2e919267b9e67741e9
|
7
|
+
data.tar.gz: 4151069e5546e83879a544aa25d34494930879893565d60bfe3a31a495e5439c630fb5781cc36a77df1e69d654fed2e53c135a782fac622b4f0d38b8c177b5bf
|
data/README.md
CHANGED
@@ -59,7 +59,8 @@ independently outside Rails.
|
|
59
59
|
|
60
60
|
Run with `--help` or `-h` for options.
|
61
61
|
|
62
|
-
4. Using a browser, go to http://localhost:3000 and you'll see:
|
62
|
+
4. Using a browser, go to `http://localhost:3000` and you'll see:
|
63
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
63
64
|
|
64
65
|
5. Follow the guidelines to start developing your application. You may find
|
65
66
|
the following resources handy:
|
@@ -75,8 +76,7 @@ We encourage you to contribute to Ruby on Rails! Please check out the
|
|
75
76
|
|
76
77
|
## Code Status
|
77
78
|
|
78
|
-
* [![Build Status](https://
|
79
|
-
* [![Dependencies](https://gemnasium.com/rails/rails.png?travis)](https://gemnasium.com/rails/rails)
|
79
|
+
* [![Build Status](https://travis-ci.org/rails/rails.png?branch=master)](https://travis-ci.org/rails/rails)
|
80
80
|
|
81
81
|
## License
|
82
82
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/guides/assets/images/getting_started/{show_action_for_posts.png → show_action_for_articles.png}
RENAMED
File without changes
|
@@ -29,7 +29,10 @@ end
|
|
29
29
|
require 'minitest/autorun'
|
30
30
|
require 'rack/test'
|
31
31
|
|
32
|
-
|
32
|
+
# Ensure backward compatibility with Minitest 4
|
33
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
34
|
+
|
35
|
+
class BugTest < Minitest::Test
|
33
36
|
include Rack::Test::Methods
|
34
37
|
|
35
38
|
def test_returns_success
|
@@ -41,4 +44,4 @@ class BugTest < MiniTest::Unit::TestCase
|
|
41
44
|
def app
|
42
45
|
Rails.application
|
43
46
|
end
|
44
|
-
end
|
47
|
+
end
|
@@ -4,6 +4,9 @@ require 'active_record'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'logger'
|
6
6
|
|
7
|
+
# Ensure backward compatibility with Minitest 4
|
8
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
9
|
+
|
7
10
|
# This connection will do for database-independent bug reports.
|
8
11
|
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
9
12
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
@@ -25,7 +28,7 @@ class Comment < ActiveRecord::Base
|
|
25
28
|
belongs_to :post
|
26
29
|
end
|
27
30
|
|
28
|
-
class BugTest <
|
31
|
+
class BugTest < Minitest::Test
|
29
32
|
def test_association_stuff
|
30
33
|
post = Post.create!
|
31
34
|
post.comments << Comment.create!
|
@@ -1,43 +1,40 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '4.0.0'
|
4
3
|
|
4
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'rails', '4.1.0'
|
5
6
|
# Use sqlite3 as the database for Active Record
|
6
7
|
gem 'sqlite3'
|
7
|
-
|
8
8
|
# Use SCSS for stylesheets
|
9
|
-
gem 'sass-rails'
|
10
|
-
|
9
|
+
gem 'sass-rails', '~> 4.0.1'
|
10
|
+
# Use Uglifier as compressor for JavaScript assets
|
11
|
+
gem 'uglifier', '>= 1.3.0'
|
11
12
|
# Use CoffeeScript for .js.coffee assets and views
|
12
|
-
gem 'coffee-rails'
|
13
|
-
|
13
|
+
gem 'coffee-rails', '~> 4.0.0'
|
14
14
|
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
15
|
-
# gem 'therubyracer',
|
16
|
-
|
17
|
-
# Use Uglifier as compressor for JavaScript assets
|
18
|
-
gem 'uglifier', '>= 1.0.3'
|
15
|
+
# gem 'therubyracer', platforms: :ruby
|
19
16
|
|
17
|
+
# Use jquery as the JavaScript library
|
20
18
|
gem 'jquery-rails'
|
21
|
-
|
22
19
|
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
23
20
|
gem 'turbolinks'
|
24
|
-
|
25
|
-
group :doc do
|
26
|
-
# bundle exec rake doc:rails generates the API under doc/api.
|
27
|
-
gem 'sdoc', require: false
|
28
|
-
end
|
29
|
-
|
30
21
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
31
|
-
gem 'jbuilder', '~>
|
22
|
+
gem 'jbuilder', '~> 2.0'
|
23
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
24
|
+
gem 'sdoc', '~> 0.4.0', group: :doc
|
32
25
|
|
33
|
-
#
|
26
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
27
|
+
gem 'spring', group: :development
|
28
|
+
|
29
|
+
# Use ActiveModel has_secure_password
|
34
30
|
# gem 'bcrypt-ruby', '~> 3.1.2'
|
35
31
|
|
36
32
|
# Use unicorn as the app server
|
37
33
|
# gem 'unicorn'
|
38
34
|
|
39
|
-
#
|
40
|
-
# gem 'capistrano', group: :development
|
35
|
+
# Use Capistrano for deployment
|
36
|
+
# gem 'capistrano-rails', group: :development
|
37
|
+
|
38
|
+
# Use debugger
|
39
|
+
# gem 'debugger', group: [:development, :test]
|
41
40
|
|
42
|
-
# To use debugger
|
43
|
-
# gem 'debugger'
|
@@ -1,120 +1,126 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (4.
|
5
|
-
actionpack (= 4.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
actionmailer (4.1.0)
|
5
|
+
actionpack (= 4.1.0)
|
6
|
+
actionview (= 4.1.0)
|
7
|
+
mail (~> 2.5.4)
|
8
|
+
actionpack (4.1.0)
|
9
|
+
actionview (= 4.1.0)
|
10
|
+
activesupport (= 4.1.0)
|
11
11
|
rack (~> 1.5.2)
|
12
12
|
rack-test (~> 0.6.2)
|
13
|
-
|
14
|
-
activesupport (= 4.
|
15
|
-
builder (~> 3.1
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
actionview (4.1.0)
|
14
|
+
activesupport (= 4.1.0)
|
15
|
+
builder (~> 3.1)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
activemodel (4.1.0)
|
18
|
+
activesupport (= 4.1.0)
|
19
|
+
builder (~> 3.1)
|
20
|
+
activerecord (4.1.0)
|
21
|
+
activemodel (= 4.1.0)
|
22
|
+
activesupport (= 4.1.0)
|
23
|
+
arel (~> 5.0.0)
|
24
|
+
activesupport (4.1.0)
|
25
|
+
i18n (~> 0.6, >= 0.6.9)
|
26
|
+
json (~> 1.7, >= 1.7.7)
|
27
|
+
minitest (~> 5.1)
|
26
28
|
thread_safe (~> 0.1)
|
27
|
-
tzinfo (~>
|
28
|
-
arel (
|
29
|
-
atomic (1.1.
|
30
|
-
builder (3.
|
31
|
-
coffee-rails (4.0.
|
29
|
+
tzinfo (~> 1.1)
|
30
|
+
arel (5.0.0)
|
31
|
+
atomic (1.1.14)
|
32
|
+
builder (3.2.2)
|
33
|
+
coffee-rails (4.0.1)
|
32
34
|
coffee-script (>= 2.2.0)
|
33
|
-
railties (>= 4.0.0
|
35
|
+
railties (>= 4.0.0, < 5.0)
|
34
36
|
coffee-script (2.2.0)
|
35
37
|
coffee-script-source
|
36
38
|
execjs
|
37
39
|
coffee-script-source (1.6.3)
|
38
40
|
erubis (2.7.0)
|
39
|
-
execjs (
|
40
|
-
multi_json (~> 1.0)
|
41
|
+
execjs (2.0.2)
|
41
42
|
hike (1.2.3)
|
42
|
-
i18n (0.6.
|
43
|
-
jbuilder (
|
43
|
+
i18n (0.6.9)
|
44
|
+
jbuilder (2.0.2)
|
44
45
|
activesupport (>= 3.0.0)
|
45
46
|
multi_json (>= 1.2.0)
|
46
|
-
jquery-rails (3.0.
|
47
|
+
jquery-rails (3.0.4)
|
47
48
|
railties (>= 3.0, < 5.0)
|
48
49
|
thor (>= 0.14, < 2.0)
|
49
|
-
json (1.8.
|
50
|
+
json (1.8.1)
|
50
51
|
mail (2.5.4)
|
51
52
|
mime-types (~> 1.16)
|
52
53
|
treetop (~> 1.4.8)
|
53
|
-
mime-types (1.
|
54
|
-
minitest (
|
55
|
-
multi_json (1.
|
54
|
+
mime-types (1.25.1)
|
55
|
+
minitest (5.2.1)
|
56
|
+
multi_json (1.8.4)
|
56
57
|
polyglot (0.3.3)
|
57
58
|
rack (1.5.2)
|
58
59
|
rack-test (0.6.2)
|
59
60
|
rack (>= 1.0)
|
60
|
-
rails (4.
|
61
|
-
actionmailer (= 4.
|
62
|
-
actionpack (= 4.
|
63
|
-
|
64
|
-
|
61
|
+
rails (4.1.0)
|
62
|
+
actionmailer (= 4.1.0)
|
63
|
+
actionpack (= 4.1.0)
|
64
|
+
actionview (= 4.1.0)
|
65
|
+
activemodel (= 4.1.0)
|
66
|
+
activerecord (= 4.1.0)
|
67
|
+
activesupport (= 4.1.0)
|
65
68
|
bundler (>= 1.3.0, < 2.0)
|
66
|
-
railties (= 4.
|
69
|
+
railties (= 4.1.0)
|
67
70
|
sprockets-rails (~> 2.0.0)
|
68
|
-
railties (4.
|
69
|
-
actionpack (= 4.
|
70
|
-
activesupport (= 4.
|
71
|
+
railties (4.1.0)
|
72
|
+
actionpack (= 4.1.0)
|
73
|
+
activesupport (= 4.1.0)
|
71
74
|
rake (>= 0.8.7)
|
72
75
|
thor (>= 0.18.1, < 2.0)
|
73
|
-
rake (10.1.
|
74
|
-
rdoc (
|
76
|
+
rake (10.1.1)
|
77
|
+
rdoc (4.1.1)
|
75
78
|
json (~> 1.4)
|
76
|
-
sass (3.2.
|
77
|
-
sass-rails (4.0.
|
78
|
-
railties (>= 4.0.0
|
79
|
+
sass (3.2.13)
|
80
|
+
sass-rails (4.0.1)
|
81
|
+
railties (>= 4.0.0, < 5.0)
|
79
82
|
sass (>= 3.1.10)
|
80
83
|
sprockets-rails (~> 2.0.0)
|
81
|
-
sdoc (0.
|
82
|
-
json (
|
83
|
-
rdoc (~>
|
84
|
-
|
84
|
+
sdoc (0.4.0)
|
85
|
+
json (~> 1.8)
|
86
|
+
rdoc (~> 4.0, < 5.0)
|
87
|
+
spring (1.0.0)
|
88
|
+
sprockets (2.10.1)
|
85
89
|
hike (~> 1.2)
|
86
90
|
multi_json (~> 1.0)
|
87
91
|
rack (~> 1.0)
|
88
92
|
tilt (~> 1.1, != 1.3.0)
|
89
|
-
sprockets-rails (2.0.
|
93
|
+
sprockets-rails (2.0.1)
|
90
94
|
actionpack (>= 3.0)
|
91
95
|
activesupport (>= 3.0)
|
92
96
|
sprockets (~> 2.8)
|
93
|
-
sqlite3 (1.3.
|
97
|
+
sqlite3 (1.3.8)
|
94
98
|
thor (0.18.1)
|
95
|
-
thread_safe (0.1.
|
99
|
+
thread_safe (0.1.3)
|
96
100
|
atomic
|
97
101
|
tilt (1.4.1)
|
98
|
-
treetop (1.4.
|
102
|
+
treetop (1.4.15)
|
99
103
|
polyglot
|
100
104
|
polyglot (>= 0.3.1)
|
101
|
-
turbolinks (
|
105
|
+
turbolinks (2.2.0)
|
102
106
|
coffee-rails
|
103
|
-
tzinfo (
|
104
|
-
|
107
|
+
tzinfo (1.1.0)
|
108
|
+
thread_safe (~> 0.1)
|
109
|
+
uglifier (2.4.0)
|
105
110
|
execjs (>= 0.3.0)
|
106
|
-
|
111
|
+
json (>= 1.8.0)
|
107
112
|
|
108
113
|
PLATFORMS
|
109
114
|
ruby
|
110
115
|
|
111
116
|
DEPENDENCIES
|
112
|
-
coffee-rails
|
113
|
-
jbuilder (~>
|
117
|
+
coffee-rails (~> 4.0.0)
|
118
|
+
jbuilder (~> 2.0)
|
114
119
|
jquery-rails
|
115
|
-
rails (= 4.
|
116
|
-
sass-rails
|
117
|
-
sdoc
|
120
|
+
rails (= 4.1.0)
|
121
|
+
sass-rails (~> 4.0.1)
|
122
|
+
sdoc (~> 0.4.0)
|
123
|
+
spring
|
118
124
|
sqlite3
|
119
125
|
turbolinks
|
120
|
-
uglifier (>= 1.0
|
126
|
+
uglifier (>= 1.3.0)
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Blog</title>
|
5
|
-
<%= stylesheet_link_tag
|
6
|
-
<%= javascript_include_tag
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
7
|
<%= csrf_meta_tags %>
|
8
8
|
</head>
|
9
9
|
<body>
|
@@ -5,7 +5,7 @@ Blog::Application.configure do
|
|
5
5
|
config.cache_classes = true
|
6
6
|
|
7
7
|
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
9
|
# and those relying on copy on write to perform better.
|
10
10
|
# Rake tasks automatically ignore this option for performance.
|
11
11
|
config.eager_load = true
|
@@ -66,7 +66,7 @@ Blog::Application.configure do
|
|
66
66
|
# config.action_mailer.raise_delivery_errors = false
|
67
67
|
|
68
68
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
-
# the I18n.default_locale when a translation
|
69
|
+
# the I18n.default_locale when a translation cannot be found).
|
70
70
|
config.i18n.fallbacks = true
|
71
71
|
|
72
72
|
# Send deprecation notices to registered listeners.
|
@@ -14,7 +14,7 @@ Blog::Application.configure do
|
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
16
|
config.serve_static_assets = true
|
17
|
-
config.static_cache_control =
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
20
20
|
config.consider_all_requests_local = true
|
@@ -574,7 +574,7 @@ The following methods have been removed because they are no longer used in the f
|
|
574
574
|
Action Mailer
|
575
575
|
-------------
|
576
576
|
|
577
|
-
Action Mailer has been given a new API with TMail being replaced out with the new [Mail](http://github.com/mikel/mail) as the
|
577
|
+
Action Mailer has been given a new API with TMail being replaced out with the new [Mail](http://github.com/mikel/mail) as the email library. Action Mailer itself has been given an almost complete re-write with pretty much every line of code touched. The result is that Action Mailer now simply inherits from Abstract Controller and wraps the Mail gem in a Rails DSL. This reduces the amount of code and duplication of other libraries in Action Mailer considerably.
|
578
578
|
|
579
579
|
* All mailers are now in `app/mailers` by default.
|
580
580
|
* Can now send email using new API with three methods: `attachments`, `headers` and `mail`.
|
@@ -30,7 +30,7 @@ guide.
|
|
30
30
|
Major Features
|
31
31
|
--------------
|
32
32
|
|
33
|
-
### Spring
|
33
|
+
### Spring Application Preloader
|
34
34
|
|
35
35
|
Spring is a Rails application preloader. It speeds up development by keeping
|
36
36
|
your application running in the background so you don't need to boot it every
|
@@ -40,27 +40,19 @@ New Rails 4.1 applications will ship with "springified" binstubs. This means
|
|
40
40
|
that `bin/rails` and `bin/rake` will automatically take advantage of preloaded
|
41
41
|
spring environments.
|
42
42
|
|
43
|
-
**
|
43
|
+
**Running rake tasks:**
|
44
44
|
|
45
45
|
```
|
46
|
-
bin/rake
|
46
|
+
bin/rake test:models
|
47
47
|
```
|
48
48
|
|
49
|
-
**
|
50
|
-
|
51
|
-
```
|
52
|
-
bin/rake test
|
53
|
-
bin/rake test test/models
|
54
|
-
bin/rake test test/models/user_test.rb
|
55
|
-
```
|
56
|
-
|
57
|
-
**running a console:**
|
49
|
+
**Running a Rails command:**
|
58
50
|
|
59
51
|
```
|
60
52
|
bin/rails console
|
61
53
|
```
|
62
54
|
|
63
|
-
**
|
55
|
+
**Spring introspection:**
|
64
56
|
|
65
57
|
```
|
66
58
|
$ bin/spring status
|
@@ -72,7 +64,7 @@ Spring is running:
|
|
72
64
|
```
|
73
65
|
|
74
66
|
Have a look at the
|
75
|
-
[Spring README](https://github.com/
|
67
|
+
[Spring README](https://github.com/rails/spring/blob/master/README.md) to
|
76
68
|
see all available features.
|
77
69
|
|
78
70
|
See the [Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#spring)
|
@@ -80,13 +72,12 @@ guide on how to migrate existing applications to use this feature.
|
|
80
72
|
|
81
73
|
### `config/secrets.yml`
|
82
74
|
|
83
|
-
Rails 4.1
|
84
|
-
|
85
|
-
|
86
|
-
APIs.
|
75
|
+
Rails 4.1 generates a new `secrets.yml` file in the `config` folder. By default,
|
76
|
+
this file contains the application's `secret_key_base`, but it could also be
|
77
|
+
used to store other secrets such as access keys for external APIs.
|
87
78
|
|
88
|
-
The secrets added to this file
|
89
|
-
For example, with the following `secrets.yml`:
|
79
|
+
The secrets added to this file are accessible via `Rails.application.secrets`.
|
80
|
+
For example, with the following `config/secrets.yml`:
|
90
81
|
|
91
82
|
```yaml
|
92
83
|
development:
|
@@ -94,16 +85,16 @@ development:
|
|
94
85
|
some_api_key: SOMEKEY
|
95
86
|
```
|
96
87
|
|
97
|
-
`Rails.application.secrets.some_api_key`
|
88
|
+
`Rails.application.secrets.some_api_key` returns `SOMEKEY` in the development
|
98
89
|
environment.
|
99
90
|
|
100
91
|
See the [Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#config-secrets-yml)
|
101
92
|
guide on how to migrate existing applications to use this feature.
|
102
93
|
|
103
|
-
### Action Pack
|
94
|
+
### Action Pack Variants
|
104
95
|
|
105
|
-
We often want to render different
|
106
|
-
tablets, and desktop browsers. Variants
|
96
|
+
We often want to render different HTML/JSON/XML templates for phones,
|
97
|
+
tablets, and desktop browsers. Variants make it easy.
|
107
98
|
|
108
99
|
The request variant is a specialization of the request format, like `:tablet`,
|
109
100
|
`:phone`, or `:desktop`.
|
@@ -143,24 +134,30 @@ respond_to do |format|
|
|
143
134
|
end
|
144
135
|
```
|
145
136
|
|
146
|
-
### Action Mailer
|
137
|
+
### Action Mailer Previews
|
147
138
|
|
148
|
-
|
139
|
+
Action Mailer previews provide a way to visually see how emails look by visiting
|
140
|
+
a special URL that renders them.
|
141
|
+
|
142
|
+
You implement a preview class whose methods return the mail object you'd like
|
143
|
+
to check:
|
149
144
|
|
150
145
|
```ruby
|
151
146
|
class NotifierPreview < ActionMailer::Preview
|
152
|
-
# Accessible from http://localhost:3000/rails/mailers/notifier/welcome
|
153
147
|
def welcome
|
154
148
|
Notifier.welcome(User.first)
|
155
149
|
end
|
156
150
|
end
|
157
151
|
```
|
158
152
|
|
159
|
-
|
160
|
-
|
153
|
+
The preview is available in http://localhost:3000/rails/mailers/notifier/welcome,
|
154
|
+
and a list of them in http://localhost:3000/rails/mailers.
|
155
|
+
|
156
|
+
By default, these preview classes live in `test/mailers/previews`.
|
157
|
+
This can be configured using the `preview_path` option.
|
161
158
|
|
162
|
-
See
|
163
|
-
[
|
159
|
+
See its
|
160
|
+
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html)
|
164
161
|
for a detailed write up.
|
165
162
|
|
166
163
|
### Active Record enums
|
@@ -178,21 +175,30 @@ conversation.active? # => false
|
|
178
175
|
conversation.status # => "archived"
|
179
176
|
|
180
177
|
Conversation.archived # => Relation for all archived Conversations
|
178
|
+
|
179
|
+
Conversation.statuses # => { "active" => 0, "archived" => 1 }
|
181
180
|
```
|
182
181
|
|
183
|
-
See
|
184
|
-
[
|
182
|
+
See its
|
183
|
+
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActiveRecord/Enum.html)
|
185
184
|
for a detailed write up.
|
186
185
|
|
187
|
-
###
|
186
|
+
### Message Verifiers
|
188
187
|
|
189
|
-
|
190
|
-
|
188
|
+
Message verifiers can be used to generate and verify signed messages. This can
|
189
|
+
be useful to safely transport sensitive data like remember-me tokens and
|
190
|
+
friends.
|
191
|
+
|
192
|
+
The method `Rails.application.message_verifier` returns a new message verifier
|
193
|
+
that signs messages with a key derived from secret_key_base and the given
|
194
|
+
message verifier name:
|
191
195
|
|
192
196
|
```ruby
|
193
|
-
|
194
|
-
Rails.application.message_verifier(
|
195
|
-
|
197
|
+
signed_token = Rails.application.message_verifier(:remember_me).generate(token)
|
198
|
+
Rails.application.message_verifier(:remember_me).verify(signed_token) # => token
|
199
|
+
|
200
|
+
Rails.application.message_verifier(:remember_me).verify(tampered_token)
|
201
|
+
# raises ActiveSupport::MessageVerifier::InvalidSignature
|
196
202
|
```
|
197
203
|
|
198
204
|
### Module#concerning
|
@@ -222,6 +228,10 @@ This example is equivalent to defining a `EventTracking` module inline,
|
|
222
228
|
extending it with `ActiveSupport::Concern`, then mixing it in to the
|
223
229
|
`Todo` class.
|
224
230
|
|
231
|
+
See its
|
232
|
+
[documentation](http://api.rubyonrails.org/v4.1.0/classes/Module/Concerning.html)
|
233
|
+
for a detailed write up and the intended use cases.
|
234
|
+
|
225
235
|
### CSRF protection from remote `<script>` tags
|
226
236
|
|
227
237
|
Cross-site request forgery (CSRF) protection now covers GET requests with
|
@@ -233,6 +243,7 @@ unless they use `xhr`. Upgrade your tests to be explicit about expecting
|
|
233
243
|
XmlHttpRequests. Instead of `post :create, format: :js`, switch to the explicit
|
234
244
|
`xhr :post, :create, format: :js`.
|
235
245
|
|
246
|
+
|
236
247
|
Railties
|
237
248
|
--------
|
238
249
|
|
@@ -259,7 +270,7 @@ for detailed changes.
|
|
259
270
|
### Notable changes
|
260
271
|
|
261
272
|
* The [Spring application
|
262
|
-
preloader](https://github.com/
|
273
|
+
preloader](https://github.com/rails/spring) is now installed
|
263
274
|
by default for new applications. It uses the development group of
|
264
275
|
the Gemfile, so will not be installed in
|
265
276
|
production. ([Pull Request](https://github.com/rails/rails/pull/12958))
|
@@ -270,9 +281,17 @@ for detailed changes.
|
|
270
281
|
* Exposed `MiddlewareStack#unshift` to environment
|
271
282
|
configuration. ([Pull Request](https://github.com/rails/rails/pull/12479))
|
272
283
|
|
273
|
-
*
|
284
|
+
* Added `Application#message_verifier` method to return a message
|
274
285
|
verifier. ([Pull Request](https://github.com/rails/rails/pull/12995))
|
275
286
|
|
287
|
+
* The `test_help.rb` file which is required by the default generated test
|
288
|
+
helper will automatically keep your test database up-to-date with
|
289
|
+
`db/schema.rb` (or `db/structure.sql`). It raises an error if
|
290
|
+
reloading the schema does not resolve all pending migrations. Opt out
|
291
|
+
with `config.active_record.maintain_test_schema = false`. ([Pull
|
292
|
+
Request](https://github.com/rails/rails/pull/13528))
|
293
|
+
|
294
|
+
|
276
295
|
Action Pack
|
277
296
|
-----------
|
278
297
|
|
@@ -292,13 +311,15 @@ for detailed changes.
|
|
292
311
|
|
293
312
|
* Removed deprecated constants from Action Controller:
|
294
313
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
314
|
+
| Removed | Successor |
|
315
|
+
|:-----------------------------------|:--------------------------------|
|
316
|
+
| ActionController::AbstractRequest | ActionDispatch::Request |
|
317
|
+
| ActionController::Request | ActionDispatch::Request |
|
318
|
+
| ActionController::AbstractResponse | ActionDispatch::Response |
|
319
|
+
| ActionController::Response | ActionDispatch::Response |
|
320
|
+
| ActionController::Routing | ActionDispatch::Routing |
|
321
|
+
| ActionController::Integration | ActionDispatch::Integration |
|
322
|
+
| ActionController::IntegrationTest | ActionDispatch::IntegrationTest |
|
302
323
|
|
303
324
|
### Notable changes
|
304
325
|
|
@@ -318,6 +339,20 @@ for detailed changes.
|
|
318
339
|
* Separated Action View completely from Action
|
319
340
|
Pack. ([Pull Request](https://github.com/rails/rails/pull/11032))
|
320
341
|
|
342
|
+
* Log which keys were affected by deep
|
343
|
+
munge. ([Pull Request](https://github.com/rails/rails/pull/13813))
|
344
|
+
|
345
|
+
* New config option `config.action_dispatch.perform_deep_munge` to opt out of
|
346
|
+
params "deep munging" that was used to address security vulnerability
|
347
|
+
CVE-2013-0155. ([Pull Request](https://github.com/rails/rails/pull/13188))
|
348
|
+
|
349
|
+
* New config option `config.action_dispatch.cookies_serializer` for specifying
|
350
|
+
a serializer for the signed and encrypted cookie jars. (Pull Requests [1](https://github.com/rails/rails/pull/13692), [2](https://github.com/rails/rails/pull/13945) / [More Details](upgrading_ruby_on_rails.html#cookies-serializer))
|
351
|
+
|
352
|
+
* Added `render :plain`, `render :html` and `render :body`. ([Pull Request](https://github.com/rails/rails/pull/14062) /
|
353
|
+
[More Details](upgrading_ruby_on_rails.html#rendering-content-from-string))
|
354
|
+
|
355
|
+
|
321
356
|
Action Mailer
|
322
357
|
-------------
|
323
358
|
|
@@ -327,9 +362,13 @@ for detailed changes.
|
|
327
362
|
|
328
363
|
### Notable changes
|
329
364
|
|
365
|
+
* Added mailer previews feature based on 37 Signals mail_view
|
366
|
+
gem. ([Commit](https://github.com/rails/rails/commit/d6dec7fcb6b8fddf8c170182d4fe64ecfc7b2261))
|
367
|
+
|
330
368
|
* Instrument the generation of Action Mailer messages. The time it takes to
|
331
369
|
generate a message is written to the log. ([Pull Request](https://github.com/rails/rails/pull/12556))
|
332
370
|
|
371
|
+
|
333
372
|
Active Record
|
334
373
|
-------------
|
335
374
|
|
@@ -356,7 +395,7 @@ for detailed changes.
|
|
356
395
|
* Removed deprecated `increment_open_transactions`.
|
357
396
|
|
358
397
|
* Removed deprecated `PostgreSQLAdapter#outside_transaction?`
|
359
|
-
|
398
|
+
method. You can use `#transaction_open?` instead.
|
360
399
|
|
361
400
|
* Removed deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
|
362
401
|
`ActiveRecord::Fixtures.default_fixture_model_name`.
|
@@ -394,6 +433,8 @@ for detailed changes.
|
|
394
433
|
* Remove implicit join references that were deprecated in 4.0.
|
395
434
|
|
396
435
|
* Removed `activerecord-deprecated_finders` as a dependency.
|
436
|
+
Please see [the gem README](https://github.com/rails/activerecord-deprecated_finders#active-record-deprecated-finders)
|
437
|
+
for more info.
|
397
438
|
|
398
439
|
* Removed usage of `implicit_readonly`. Please use `readonly` method
|
399
440
|
explicitly to mark records as
|
@@ -403,16 +444,25 @@ for detailed changes.
|
|
403
444
|
|
404
445
|
* Deprecated `quoted_locking_column` method, which isn't used anywhere.
|
405
446
|
|
406
|
-
* Deprecated the delegation of Array bang methods for associations.
|
407
|
-
To use them, instead first call `#to_a` on the association to access the
|
408
|
-
array to be acted
|
409
|
-
on. ([Pull Request](https://github.com/rails/rails/pull/12129))
|
410
|
-
|
411
447
|
* Deprecated `ConnectionAdapters::SchemaStatements#distinct`,
|
412
448
|
as it is no longer used by internals. ([Pull Request](https://github.com/rails/rails/pull/10556))
|
413
449
|
|
450
|
+
* Deprecated `rake db:test:*` tasks as the test database is now
|
451
|
+
automatically maintained. See railties release notes. ([Pull
|
452
|
+
Request](https://github.com/rails/rails/pull/13528))
|
453
|
+
|
454
|
+
* Deprecate unused `ActiveRecord::Base.symbolized_base_class`
|
455
|
+
and `ActiveRecord::Base.symbolized_sti_name` without
|
456
|
+
replacement. [Commit](https://github.com/rails/rails/commit/97e7ca48c139ea5cce2fa9b4be631946252a1ebd)
|
457
|
+
|
414
458
|
### Notable changes
|
415
459
|
|
460
|
+
* Default scopes are no longer overriden by chained conditions.
|
461
|
+
|
462
|
+
Before this change when you defined a `default_scope` in a model
|
463
|
+
it was overriden by chained conditions in the same field. Now it
|
464
|
+
is merged like any other scope. [More Details](upgrading_ruby_on_rails.html#changes-on-default-scopes).
|
465
|
+
|
416
466
|
* Added `ActiveRecord::Base.to_param` for convenient "pretty" URLs derived from
|
417
467
|
a model's attribute or
|
418
468
|
method. ([Pull Request](https://github.com/rails/rails/pull/12891))
|
@@ -473,6 +523,36 @@ for detailed changes.
|
|
473
523
|
object. Helper methods used by multiple fixtures should be defined on modules
|
474
524
|
included in `ActiveRecord::FixtureSet.context_class`. ([Pull Request](https://github.com/rails/rails/pull/13022))
|
475
525
|
|
526
|
+
* Don't create or drop the test database if RAILS_ENV is specified
|
527
|
+
explicitly. ([Pull Request](https://github.com/rails/rails/pull/13629))
|
528
|
+
|
529
|
+
* `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
|
530
|
+
to an `Array` by calling `#to_a` before using these methods. ([Pull Request](https://github.com/rails/rails/pull/13314))
|
531
|
+
|
532
|
+
* `find_in_batches`, `find_each`, `Result#each` and `Enumerable#index_by` now
|
533
|
+
return an `Enumerator` that can calculate its
|
534
|
+
size. ([Pull Request](https://github.com/rails/rails/pull/13938))
|
535
|
+
|
536
|
+
* `scope`, `enum` and Associations now raise on "dangerous" name
|
537
|
+
conflicts. ([Pull Request](https://github.com/rails/rails/pull/13450),
|
538
|
+
[Pull Request](https://github.com/rails/rails/pull/13896))
|
539
|
+
|
540
|
+
* `second` through `fifth` methods act like the `first`
|
541
|
+
finder. ([Pull Request](https://github.com/rails/rails/pull/13757))
|
542
|
+
|
543
|
+
* Make `touch` fire the `after_commit` and `after_rollback`
|
544
|
+
callbacks. ([Pull Request](https://github.com/rails/rails/pull/12031))
|
545
|
+
|
546
|
+
* Enable partial indexes for `sqlite >=
|
547
|
+
3.8.0`. ([Pull Request](https://github.com/rails/rails/pull/13350))
|
548
|
+
|
549
|
+
* Make `change_column_null`
|
550
|
+
revertable. ([Commit](https://github.com/rails/rails/commit/724509a9d5322ff502aefa90dd282ba33a281a96))
|
551
|
+
|
552
|
+
* Added a flag to disable schema dump after migration. This is set to `false`
|
553
|
+
by defualt in the production environment for new applications. ([Pull Request](https://github.com/rails/rails/pull/13948))
|
554
|
+
|
555
|
+
|
476
556
|
Active Model
|
477
557
|
------------
|
478
558
|
|
@@ -490,6 +570,13 @@ for detailed changes.
|
|
490
570
|
* Added new API methods `reset_changes` and `changes_applied` to
|
491
571
|
`ActiveModel::Dirty` that control changes state.
|
492
572
|
|
573
|
+
* Ability to specify multiple contexts when defining a
|
574
|
+
validation. ([Pull Request](https://github.com/rails/rails/pull/13754))
|
575
|
+
|
576
|
+
* `attribute_changed?` now accepts a hash to check if the attribute was changed
|
577
|
+
`:from` and/or `:to` a given
|
578
|
+
value. ([Pull Request](https://github.com/rails/rails/pull/13131))
|
579
|
+
|
493
580
|
|
494
581
|
Active Support
|
495
582
|
--------------
|
@@ -516,7 +603,7 @@ for detailed changes.
|
|
516
603
|
|
517
604
|
* Removed deprecated `Module#local_constant_names` in favor of `Module#local_constants`.
|
518
605
|
|
519
|
-
* Removed deprecated `DateTime.local_offset` in favor of `DateTime.
|
606
|
+
* Removed deprecated `DateTime.local_offset` in favor of `DateTime.civil_from_format`.
|
520
607
|
|
521
608
|
* Removed deprecated `Logger` core extensions (`core_ext/logger.rb`).
|
522
609
|
|
@@ -540,6 +627,12 @@ for detailed changes.
|
|
540
627
|
* Removed deprecated `assert_present` and `assert_blank` methods, use `assert
|
541
628
|
object.blank?` and `assert object.present?` instead.
|
542
629
|
|
630
|
+
* Remove deprecated `#filter` method for filter objects, use the corresponding
|
631
|
+
method instead (e.g. `#before` for a before filter).
|
632
|
+
|
633
|
+
* Removed 'cow' => 'kine' irregular inflection from default
|
634
|
+
inflections. ([Commit](https://github.com/rails/rails/commit/c300dca9963bda78b8f358dbcb59cabcdc5e1dc9))
|
635
|
+
|
543
636
|
### Deprecations
|
544
637
|
|
545
638
|
* Deprecated `Numeric#{ago,until,since,from_now}`, the user is expected to
|
@@ -556,11 +649,14 @@ for detailed changes.
|
|
556
649
|
[More Details](upgrading_ruby_on_rails.html#changes-in-json-handling))
|
557
650
|
|
558
651
|
* Deprecated `ActiveSupport.encode_big_decimal_as_string` option. This feature has
|
559
|
-
been
|
652
|
+
been extracted into the [activesupport-json_encoder](https://github.com/rails/activesupport-json_encoder)
|
560
653
|
gem.
|
561
654
|
([Pull Request](https://github.com/rails/rails/pull/13060) /
|
562
655
|
[More Details](upgrading_ruby_on_rails.html#changes-in-json-handling))
|
563
656
|
|
657
|
+
* Deprecate custom `BigDecimal`
|
658
|
+
serialization. ([Pull Request](https://github.com/rails/rails/pull/13911))
|
659
|
+
|
564
660
|
### Notable changes
|
565
661
|
|
566
662
|
* `ActiveSupport`'s JSON encoder has been rewritten to take advantage of the
|
@@ -573,9 +669,12 @@ for detailed changes.
|
|
573
669
|
[More Details](upgrading_ruby_on_rails.html#changes-in-json-handling))
|
574
670
|
|
575
671
|
* Added `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These
|
576
|
-
methods change current time to the given time or
|
577
|
-
`Time.now` and
|
578
|
-
|
672
|
+
methods change current time to the given time or duration by stubbing
|
673
|
+
`Time.now` and `Date.today`.
|
674
|
+
|
675
|
+
* Added `ActiveSupport::Testing::TimeHelpers#travel_back`. This method returns
|
676
|
+
the current time to the original state, by removing the stubs added by `travel`
|
677
|
+
and `travel_to`. ([Pull Request](https://github.com/rails/rails/pull/13884))
|
579
678
|
|
580
679
|
* Added `Numeric#in_milliseconds`, like `1.hour.in_milliseconds`, so we can feed
|
581
680
|
them to JavaScript functions like
|
@@ -586,11 +685,32 @@ for detailed changes.
|
|
586
685
|
`at_middle_of_day` as
|
587
686
|
aliases. ([Pull Request](https://github.com/rails/rails/pull/10879))
|
588
687
|
|
688
|
+
* Added `Date#all_week/month/quarter/year` for generating date
|
689
|
+
ranges. ([Pull Request](https://github.com/rails/rails/pull/9685))
|
690
|
+
|
691
|
+
* Added `Time.zone.yesterday` and
|
692
|
+
`Time.zone.tomorrow`. ([Pull Request](https://github.com/rails/rails/pull/12822))
|
693
|
+
|
589
694
|
* Added `String#remove(pattern)` as a short-hand for the common pattern of
|
590
695
|
`String#gsub(pattern,'')`. ([Commit](https://github.com/rails/rails/commit/5da23a3f921f0a4a3139495d2779ab0d3bd4cb5f))
|
591
696
|
|
592
|
-
*
|
593
|
-
|
697
|
+
* Added `Hash#compact` and `Hash#compact!` for removing items with nil value
|
698
|
+
from hash. ([Pull Request](https://github.com/rails/rails/pull/13632))
|
699
|
+
|
700
|
+
* `blank?` and `present?` commit to return
|
701
|
+
singletons. ([Commit](https://github.com/rails/rails/commit/126dc47665c65cd129967cbd8a5926dddd0aa514))
|
702
|
+
|
703
|
+
* Default the new `I18n.enforce_available_locales` config to `true`, meaning
|
704
|
+
`I18n` will make sure that all locales passed to it must be declared in the
|
705
|
+
`available_locales`
|
706
|
+
list. ([Pull Request](https://github.com/rails/rails/commit/8e21ae37ad9fef6b7393a84f9b5f2e18a831e49a))
|
707
|
+
|
708
|
+
* Introduce Module#concerning: a natural, low-ceremony way to separate
|
709
|
+
responsibilities within a
|
710
|
+
class. ([Commit](https://github.com/rails/rails/commit/1eee0ca6de975b42524105a59e0521d18b38ab81))
|
711
|
+
|
712
|
+
* Added `Object#present_in` to simplify value whitelisting. ([Commit](https://github.com/rails/rails/commit/4edca106daacc5a159289eae255207d160f22396))
|
713
|
+
|
594
714
|
|
595
715
|
Credits
|
596
716
|
-------
|