railties 4.0.0.beta1 → 4.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +120 -27
- data/RDOC_MAIN.rdoc +73 -0
- data/bin/rails +3 -1
- data/lib/rails/api/task.rb +158 -0
- data/lib/rails/app_rails_loader.rb +44 -20
- data/lib/rails/application.rb +55 -32
- data/lib/rails/application/configuration.rb +9 -7
- data/lib/rails/commands.rb +2 -0
- data/lib/rails/commands/console.rb +3 -1
- data/lib/rails/commands/server.rb +6 -2
- data/lib/rails/engine.rb +4 -3
- data/lib/rails/generators/actions.rb +1 -1
- data/lib/rails/generators/app_base.rb +52 -30
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +9 -9
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -2
- data/lib/rails/generators/generated_attribute.rb +4 -0
- data/lib/rails/generators/named_base.rb +2 -1
- data/lib/rails/generators/rails/app/templates/Gemfile +9 -4
- data/lib/rails/generators/rails/app/templates/config.ru +1 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb +3 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/public/404.html +41 -10
- data/lib/rails/generators/rails/app/templates/public/422.html +42 -10
- data/lib/rails/generators/rails/app/templates/public/500.html +41 -10
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb +1 -1
- data/lib/rails/generators/rails/model/USAGE +16 -10
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +9 -5
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +0 -3
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +0 -8
- data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +4 -8
- data/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js +13 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css +13 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
- data/lib/rails/generators/test_case.rb +6 -211
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +7 -9
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
- data/lib/rails/generators/testing/assertions.rb +121 -0
- data/lib/rails/generators/testing/behaviour.rb +106 -0
- data/lib/rails/generators/testing/setup_and_teardown.rb +18 -0
- data/lib/rails/info.rb +2 -2
- data/lib/rails/tasks/documentation.rake +2 -46
- data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
- data/lib/rails/test_unit/railtie.rb +4 -0
- data/lib/rails/test_unit/sub_test_task.rb +78 -1
- data/lib/rails/test_unit/testing.rake +32 -42
- data/lib/rails/version.rb +3 -3
- metadata +15 -23
- data/lib/rails/generators/rails/app/templates/app/assets/images/rails.png +0 -0
@@ -13,8 +13,17 @@
|
|
13
13
|
|
14
14
|
<% attributes.each do |attribute| -%>
|
15
15
|
<div class="field">
|
16
|
-
|
16
|
+
<% if attribute.password_digest? -%>
|
17
|
+
<%%= f.label :password %><br>
|
18
|
+
<%%= f.password_field :password %>
|
19
|
+
</div>
|
20
|
+
<div>
|
21
|
+
<%%= f.label :password_confirmation %><br>
|
22
|
+
<%%= f.password_field :password_confirmation %>
|
23
|
+
<% else -%>
|
24
|
+
<%%= f.label :<%= attribute.name %> %><br>
|
17
25
|
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
26
|
+
<% end -%>
|
18
27
|
</div>
|
19
28
|
<% end -%>
|
20
29
|
<div class="actions">
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<table>
|
4
4
|
<thead>
|
5
5
|
<tr>
|
6
|
-
<% attributes.each do |attribute| -%>
|
6
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
7
7
|
<th><%= attribute.human_name %></th>
|
8
8
|
<% end -%>
|
9
9
|
<th></th>
|
@@ -14,18 +14,18 @@
|
|
14
14
|
|
15
15
|
<tbody>
|
16
16
|
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
17
|
-
|
18
|
-
<% attributes.each do |attribute| -%>
|
19
|
-
|
17
|
+
<tr>
|
18
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
19
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
20
20
|
<% end -%>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
|
22
|
+
<td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
23
|
+
<td><%%= link_to 'Destroy', <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
25
|
<%% end %>
|
26
26
|
</tbody>
|
27
27
|
</table>
|
28
28
|
|
29
|
-
<br
|
29
|
+
<br>
|
30
30
|
|
31
31
|
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<p id="notice"><%%= notice %></p>
|
2
2
|
|
3
|
-
<% attributes.each do |attribute| -%>
|
3
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
4
4
|
<p>
|
5
5
|
<strong><%= attribute.human_name %>:</strong>
|
6
6
|
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
|
7
7
|
</p>
|
8
8
|
|
9
9
|
<% end -%>
|
10
|
-
|
11
10
|
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
|
12
11
|
<%%= link_to 'Back', <%= index_helper %>_path %>
|
@@ -40,7 +40,7 @@ module Rails
|
|
40
40
|
|
41
41
|
def indent(content, multiplier = 2)
|
42
42
|
spaces = " " * multiplier
|
43
|
-
content
|
43
|
+
content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
|
44
44
|
end
|
45
45
|
|
46
46
|
def wrap_with_namespace(content)
|
@@ -163,6 +163,7 @@ module Rails
|
|
163
163
|
def attributes_names
|
164
164
|
@attributes_names ||= attributes.each_with_object([]) do |a, names|
|
165
165
|
names << a.column_name
|
166
|
+
names << 'password_confirmation' if a.password_digest?
|
166
167
|
names << "#{a.name}_type" if a.polymorphic?
|
167
168
|
end
|
168
169
|
end
|
@@ -12,16 +12,21 @@ source 'https://rubygems.org'
|
|
12
12
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
13
13
|
gem 'jbuilder', '~> 1.0.1'
|
14
14
|
|
15
|
-
|
15
|
+
group :doc do
|
16
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
17
|
+
gem 'sdoc', require: false
|
18
|
+
end
|
19
|
+
|
20
|
+
# Use ActiveModel has_secure_password
|
16
21
|
# gem 'bcrypt-ruby', '~> 3.0.0'
|
17
22
|
|
18
23
|
# Use unicorn as the app server
|
19
24
|
# gem 'unicorn'
|
20
25
|
|
21
|
-
#
|
26
|
+
# Use Capistrano for deployment
|
22
27
|
# gem 'capistrano', group: :development
|
23
28
|
|
24
29
|
<% unless defined?(JRUBY_VERSION) -%>
|
25
|
-
#
|
26
|
-
# gem 'debugger'
|
30
|
+
# Use debugger
|
31
|
+
# gem 'debugger', group: [:development, :test]
|
27
32
|
<% end -%>
|
@@ -11,8 +11,9 @@ require "action_mailer/railtie"
|
|
11
11
|
<%= comment_if :skip_test_unit %>require "rails/test_unit/railtie"
|
12
12
|
<% end -%>
|
13
13
|
|
14
|
-
#
|
15
|
-
|
14
|
+
# Require the gems listed in Gemfile, including any gems
|
15
|
+
# you've limited to :test, :development, or :production.
|
16
|
+
Bundler.require(:default, Rails.env)
|
16
17
|
|
17
18
|
module <%= app_const_base %>
|
18
19
|
class Application < Rails::Application
|
@@ -26,6 +26,8 @@
|
|
26
26
|
|
27
27
|
<%- unless options.skip_sprockets? -%>
|
28
28
|
# Debug mode disables concatenation and preprocessing of assets.
|
29
|
+
# This option may cause significant delays in view rendering with a large
|
30
|
+
# number of complex assets.
|
29
31
|
config.assets.debug = true
|
30
32
|
<%- end -%>
|
31
33
|
end
|
@@ -24,10 +24,10 @@
|
|
24
24
|
|
25
25
|
<%- unless options.skip_sprockets? -%>
|
26
26
|
# Compress JavaScripts and CSS.
|
27
|
-
config.assets.js_compressor
|
27
|
+
config.assets.js_compressor = :uglifier
|
28
28
|
# config.assets.css_compressor = :sass
|
29
29
|
|
30
|
-
#
|
30
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
31
31
|
config.assets.compile = false
|
32
32
|
|
33
33
|
# Generate digests for assets URLs.
|
@@ -13,7 +13,7 @@
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.serve_static_assets
|
16
|
+
config.serve_static_assets = true
|
17
17
|
config.static_cache_control = "public, max-age=3600"
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
# Your secret key for verifying the integrity of signed cookies.
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
|
6
6
|
# Make sure the secret is at least 30 characters and all random,
|
@@ -3,16 +3,47 @@
|
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
5
|
<style>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
16
47
|
</style>
|
17
48
|
</head>
|
18
49
|
|
@@ -3,16 +3,47 @@
|
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
5
|
<style>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
16
47
|
</style>
|
17
48
|
</head>
|
18
49
|
|
@@ -22,5 +53,6 @@
|
|
22
53
|
<h1>The change you wanted was rejected.</h1>
|
23
54
|
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
55
|
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
25
57
|
</body>
|
26
58
|
</html>
|
@@ -3,16 +3,47 @@
|
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
5
|
<style>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
16
47
|
</style>
|
17
48
|
</head>
|
18
49
|
|
@@ -52,20 +52,26 @@ Available field types:
|
|
52
52
|
|
53
53
|
`rails generate model product supplier:references{polymorphic}`
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
For integer, string, text and binary fields an integer in curly braces will
|
56
|
+
be set as the limit:
|
57
57
|
|
58
|
-
|
59
|
-
default Set a default value for the field
|
60
|
-
precision Defines the precision for the decimal fields
|
61
|
-
scale Defines the scale for the decimal fields
|
62
|
-
uniq Defines the field values as unique
|
63
|
-
index Will add an index on the field
|
58
|
+
`rails generate model user pseudo:string{30}`
|
64
59
|
|
65
|
-
|
60
|
+
For decimal two integers separated by a comma in curly braces will be used
|
61
|
+
for precision and scale:
|
62
|
+
|
63
|
+
`rails generate model product price:decimal{10,2}`
|
64
|
+
|
65
|
+
You can add a `:uniq` or `:index` suffix for unique or standard indexes
|
66
|
+
respectively:
|
66
67
|
|
67
|
-
`rails generate model user pseudo:string{30}`
|
68
68
|
`rails generate model user pseudo:string:uniq`
|
69
|
+
`rails generate model user pseudo:string:index`
|
70
|
+
|
71
|
+
You can combine any single curly brace option with the index options:
|
72
|
+
|
73
|
+
`rails generate model user username:string{30}:uniq`
|
74
|
+
`rails generate model product supplier:references{polymorphic}:index`
|
69
75
|
|
70
76
|
|
71
77
|
Examples:
|
@@ -94,6 +94,11 @@ task default: :test
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
def test_dummy_assets
|
98
|
+
template "rails/javascripts.js", "#{dummy_path}/app/assets/javascripts/application.js", force: true
|
99
|
+
template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
|
100
|
+
end
|
101
|
+
|
97
102
|
def test_dummy_clean
|
98
103
|
inside dummy_path do
|
99
104
|
remove_file ".gitignore"
|
@@ -101,8 +106,6 @@ task default: :test
|
|
101
106
|
remove_file "doc"
|
102
107
|
remove_file "Gemfile"
|
103
108
|
remove_file "lib/tasks"
|
104
|
-
remove_file "app/assets/images/rails.png"
|
105
|
-
remove_file "public/index.html"
|
106
109
|
remove_file "public/robots.txt"
|
107
110
|
remove_file "README"
|
108
111
|
remove_file "test"
|
@@ -112,7 +115,7 @@ task default: :test
|
|
112
115
|
|
113
116
|
def stylesheets
|
114
117
|
if mountable?
|
115
|
-
copy_file "
|
118
|
+
copy_file "rails/stylesheets.css",
|
116
119
|
"app/assets/stylesheets/#{name}/application.css"
|
117
120
|
elsif full?
|
118
121
|
empty_directory_with_keep_file "app/assets/stylesheets/#{name}"
|
@@ -123,8 +126,8 @@ task default: :test
|
|
123
126
|
return if options.skip_javascript?
|
124
127
|
|
125
128
|
if mountable?
|
126
|
-
template "
|
127
|
-
|
129
|
+
template "rails/javascripts.js",
|
130
|
+
"app/assets/javascripts/#{name}/application.js"
|
128
131
|
elsif full?
|
129
132
|
empty_directory_with_keep_file "app/assets/javascripts/#{name}"
|
130
133
|
end
|
@@ -263,6 +266,7 @@ task default: :test
|
|
263
266
|
build(:generate_test_dummy)
|
264
267
|
store_application_definition!
|
265
268
|
build(:test_dummy_config)
|
269
|
+
build(:test_dummy_assets)
|
266
270
|
build(:test_dummy_clean)
|
267
271
|
# ensure that bin/rails has proper dummy_path
|
268
272
|
build(:bin, true)
|