railties 4.0.13 → 4.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +155 -385
- data/README.rdoc +1 -1
- data/bin/rails +1 -1
- data/lib/rails.rb +11 -13
- data/lib/rails/all.rb +1 -0
- data/lib/rails/api/task.rb +9 -12
- data/lib/rails/app_rails_loader.rb +2 -2
- data/lib/rails/application.rb +154 -149
- data/lib/rails/application/configuration.rb +1 -14
- data/lib/rails/application/default_middleware_stack.rb +99 -0
- data/lib/rails/application/finisher.rb +2 -0
- data/lib/rails/application_controller.rb +16 -0
- data/lib/rails/cli.rb +1 -2
- data/lib/rails/commands.rb +2 -94
- data/lib/rails/commands/application.rb +2 -28
- data/lib/rails/commands/commands_tasks.rb +174 -0
- data/lib/rails/commands/console.rb +2 -2
- data/lib/rails/commands/dbconsole.rb +1 -1
- data/lib/rails/commands/plugin.rb +23 -0
- data/lib/rails/commands/runner.rb +1 -1
- data/lib/rails/commands/server.rb +46 -30
- data/lib/rails/configuration.rb +4 -1
- data/lib/rails/console/helpers.rb +6 -0
- data/lib/rails/engine.rb +29 -18
- data/lib/rails/engine/commands.rb +1 -1
- data/lib/rails/engine/railties.rb +0 -8
- data/lib/rails/generators.rb +4 -3
- data/lib/rails/generators/actions.rb +1 -1
- data/lib/rails/generators/active_model.rb +0 -8
- data/lib/rails/generators/app_base.rb +213 -74
- data/lib/rails/generators/base.rb +17 -16
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -3
- data/lib/rails/generators/migration.rb +18 -26
- data/lib/rails/generators/named_base.rb +4 -7
- data/lib/rails/generators/rails/app/app_generator.rb +91 -5
- data/lib/rails/generators/rails/app/templates/Gemfile +20 -15
- data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +2 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -3
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +5 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb +2 -0
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +7 -10
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +11 -31
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +25 -29
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +8 -10
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +8 -11
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +6 -3
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +8 -22
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +7 -9
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +9 -12
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +8 -8
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml +7 -17
- data/lib/rails/generators/rails/app/templates/config/environment.rb +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -5
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -4
- 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/config/{initializers/secret_token.rb.tt → secrets.yml} +10 -2
- data/lib/rails/generators/rails/app/templates/public/404.html +20 -11
- data/lib/rails/generators/rails/app/templates/public/422.html +20 -11
- data/lib/rails/generators/rails/app/templates/public/500.html +19 -10
- data/lib/rails/generators/rails/controller/USAGE +1 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +35 -1
- data/lib/rails/generators/rails/generator/USAGE +1 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -0
- data/lib/rails/generators/rails/model/USAGE +5 -5
- data/lib/rails/generators/rails/{plugin_new → plugin}/USAGE +0 -0
- data/lib/rails/generators/rails/{plugin_new/plugin_new_generator.rb → plugin/plugin_generator.rb} +10 -4
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/%name%.gemspec +1 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/Gemfile +16 -1
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/MIT-LICENSE +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/README.rdoc +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/Rakefile +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/controllers/%name%/application_controller.rb.tt +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/helpers/%name%/application_helper.rb.tt +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/app/views/layouts/%name%/application.html.erb.tt +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/bin/rails.tt +0 -4
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/config/routes.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/gitignore +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%/engine.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/%name%/version.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/lib/tasks/%name%_tasks.rake +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/application.rb +1 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/boot.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/javascripts.js +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/routes.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/rails/stylesheets.css +5 -3
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/%name%_test.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/integration/navigation_test.rb +0 -0
- data/lib/rails/generators/rails/{plugin_new → plugin}/templates/test/test_helper.rb +0 -0
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +2 -2
- data/lib/rails/generators/resource_helpers.rb +20 -5
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +26 -0
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb +16 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -1
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb +11 -0
- data/lib/rails/generators/testing/assertions.rb +1 -1
- data/lib/rails/generators/testing/behaviour.rb +3 -13
- data/lib/rails/info.rb +5 -3
- data/lib/rails/info_controller.rb +5 -15
- data/lib/rails/mailers_controller.rb +73 -0
- data/lib/rails/paths.rb +13 -18
- data/lib/rails/rack/debugger.rb +2 -2
- data/lib/rails/rack/logger.rb +1 -1
- data/lib/rails/railtie.rb +38 -2
- data/lib/rails/source_annotation_extractor.rb +2 -2
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/tasks/documentation.rake +0 -5
- data/lib/rails/tasks/engine.rake +1 -1
- data/lib/rails/tasks/framework.rake +2 -12
- data/lib/rails/templates/layouts/application.html.erb +2 -2
- data/lib/rails/templates/rails/mailers/email.html.erb +98 -0
- data/lib/rails/templates/rails/mailers/index.html.erb +8 -0
- data/lib/rails/templates/rails/mailers/mailer.html.erb +6 -0
- data/lib/rails/test_help.rb +4 -1
- data/lib/rails/test_unit/sub_test_task.rb +44 -3
- data/lib/rails/test_unit/testing.rake +9 -111
- data/lib/rails/version.rb +3 -3
- data/lib/rails/welcome_controller.rb +4 -3
- metadata +99 -76
- data/lib/rails/commands/plugin_new.rb +0 -9
- data/lib/rails/generators/actions/create_migration.rb +0 -68
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Rails.application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
@@ -20,7 +20,7 @@
|
|
20
20
|
config.active_support.deprecation = :log
|
21
21
|
|
22
22
|
<%- unless options.skip_active_record? -%>
|
23
|
-
# Raise an error on page load if there are pending migrations
|
23
|
+
# Raise an error on page load if there are pending migrations.
|
24
24
|
config.active_record.migration_error = :page_load
|
25
25
|
|
26
26
|
<%- end -%>
|
@@ -30,7 +30,4 @@
|
|
30
30
|
# number of complex assets.
|
31
31
|
config.assets.debug = true
|
32
32
|
<%- end -%>
|
33
|
-
|
34
|
-
# Raises error for missing translations
|
35
|
-
# config.action_view.raise_on_missing_translations = true
|
36
33
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Rails.application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
@@ -33,7 +33,4 @@
|
|
33
33
|
|
34
34
|
# Print deprecation notices to the stderr.
|
35
35
|
config.active_support.deprecation = :stderr
|
36
|
-
|
37
|
-
# Raises error for missing translations
|
38
|
-
# config.action_view.raise_on_missing_translations = true
|
39
36
|
end
|
data/lib/rails/generators/rails/app/templates/config/{initializers/secret_token.rb.tt → secrets.yml}
RENAMED
@@ -7,6 +7,14 @@
|
|
7
7
|
# no regular words or you'll be exposed to dictionary attacks.
|
8
8
|
# You can use `rake secret` to generate a secure secret key.
|
9
9
|
|
10
|
-
# Make sure
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
11
|
# if you're sharing your code publicly.
|
12
|
-
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: <%= app_secret %>
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: <%= app_secret %>
|
18
|
+
|
19
|
+
production:
|
20
|
+
secret_key_base: <%= app_secret %>
|
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,9 +57,11 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/404.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,9 +57,11 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/422.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,8 +57,10 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/500.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
54
64
|
</div>
|
55
|
-
<p>If you are the application owner check the logs for more information.</p>
|
56
65
|
</body>
|
57
66
|
</html>
|
@@ -10,11 +10,45 @@ module Rails
|
|
10
10
|
|
11
11
|
def add_routes
|
12
12
|
actions.reverse.each do |action|
|
13
|
-
route
|
13
|
+
route generate_routing_code(action)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
hook_for :template_engine, :test_framework, :helper, :assets
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# This method creates nested route entry for namespaced resources.
|
22
|
+
# For eg. rails g controller foo/bar/baz index
|
23
|
+
# Will generate -
|
24
|
+
# namespace :foo do
|
25
|
+
# namespace :bar do
|
26
|
+
# get "baz/index"
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
def generate_routing_code(action)
|
30
|
+
depth = class_path.length
|
31
|
+
# Create 'namespace' ladder
|
32
|
+
# namespace :foo do
|
33
|
+
# namespace :bar do
|
34
|
+
namespace_ladder = class_path.each_with_index.map do |ns, i|
|
35
|
+
indent("namespace :#{ns} do\n", i * 2)
|
36
|
+
end.join
|
37
|
+
|
38
|
+
# Create route
|
39
|
+
# get "baz/index"
|
40
|
+
route = indent(%{get "#{file_name}/#{action}"\n}, depth * 2)
|
41
|
+
|
42
|
+
# Create `end` ladder
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
end_ladder = (1..depth).reverse_each.map do |i|
|
46
|
+
indent("end\n", i * 2)
|
47
|
+
end.join
|
48
|
+
|
49
|
+
# Combine the 3 parts to generate complete route entry
|
50
|
+
namespace_ladder + route + end_ladder
|
51
|
+
end
|
18
52
|
end
|
19
53
|
end
|
20
54
|
end
|
@@ -46,18 +46,18 @@ Available field types:
|
|
46
46
|
|
47
47
|
`rails generate model photo title:string album:references`
|
48
48
|
|
49
|
-
It will generate an album_id column. You should generate
|
50
|
-
you will use a `belongs_to` association for instance. `references` also
|
51
|
-
|
49
|
+
It will generate an `album_id` column. You should generate these kinds of fields when
|
50
|
+
you will use a `belongs_to` association, for instance. `references` also supports
|
51
|
+
polymorphism, you can enable polymorphism like this:
|
52
52
|
|
53
53
|
`rails generate model product supplier:references{polymorphic}`
|
54
54
|
|
55
|
-
For integer, string, text and binary fields an integer in curly braces will
|
55
|
+
For integer, string, text and binary fields, an integer in curly braces will
|
56
56
|
be set as the limit:
|
57
57
|
|
58
58
|
`rails generate model user pseudo:string{30}`
|
59
59
|
|
60
|
-
For decimal two integers separated by a comma in curly braces will be used
|
60
|
+
For decimal, two integers separated by a comma in curly braces will be used
|
61
61
|
for precision and scale:
|
62
62
|
|
63
63
|
`rails generate model product 'price:decimal{10,2}'`
|
File without changes
|
data/lib/rails/generators/rails/{plugin_new/plugin_new_generator.rb → plugin/plugin_generator.rb}
RENAMED
@@ -154,7 +154,7 @@ task default: :test
|
|
154
154
|
end
|
155
155
|
|
156
156
|
module Generators
|
157
|
-
class
|
157
|
+
class PluginGenerator < AppBase # :nodoc:
|
158
158
|
add_shared_options_for "plugin"
|
159
159
|
|
160
160
|
alias_method :plugin_path, :app_path
|
@@ -176,12 +176,16 @@ task default: :test
|
|
176
176
|
"skip adding entry to Gemfile"
|
177
177
|
|
178
178
|
def initialize(*args)
|
179
|
-
raise Error, "Options should be given after the plugin name. For details run: rails plugin new --help" if args[0].blank?
|
180
|
-
|
181
179
|
@dummy_path = nil
|
182
180
|
super
|
181
|
+
|
182
|
+
unless plugin_path
|
183
|
+
raise Error, "Plugin name should be provided in arguments. For details run: rails plugin new --help"
|
184
|
+
end
|
183
185
|
end
|
184
186
|
|
187
|
+
public_task :set_default_accessors!
|
188
|
+
public_task :apply_rails_template
|
185
189
|
public_task :create_root
|
186
190
|
|
187
191
|
def create_root_files
|
@@ -238,7 +242,6 @@ task default: :test
|
|
238
242
|
build(:leftovers)
|
239
243
|
end
|
240
244
|
|
241
|
-
public_task :apply_rails_template, :run_bundle
|
242
245
|
|
243
246
|
def name
|
244
247
|
@name ||= begin
|
@@ -252,6 +255,9 @@ task default: :test
|
|
252
255
|
end
|
253
256
|
end
|
254
257
|
|
258
|
+
public_task :run_bundle
|
259
|
+
public_task :replay_template
|
260
|
+
|
255
261
|
protected
|
256
262
|
|
257
263
|
def app_templates_dir
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = "TODO"
|
13
13
|
s.summary = "TODO: Summary of <%= camelized %>."
|
14
14
|
s.description = "TODO: Description of <%= camelized %>."
|
15
|
+
s.license = "MIT"
|
15
16
|
|
16
17
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
17
18
|
<% unless options.skip_test_unit? -%>
|
@@ -23,8 +23,23 @@ end
|
|
23
23
|
<% if options.dev? || options.edge? -%>
|
24
24
|
# Your gem is dependent on dev or edge Rails. Once you can lock this
|
25
25
|
# dependency down to a specific version, move it to your gemspec.
|
26
|
-
|
26
|
+
<% max_width = gemfile_entries.map { |g| g.name.length }.max -%>
|
27
|
+
<% gemfile_entries.each do |gem| -%>
|
28
|
+
<% if gem.comment -%>
|
27
29
|
|
30
|
+
# <%= gem.comment %>
|
28
31
|
<% end -%>
|
32
|
+
<%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<% if gem.version -%>
|
33
|
+
, '<%= gem.version %>'
|
34
|
+
<% elsif gem.options.any? -%>
|
35
|
+
,<%= gem.padding(max_width) %><%= gem.options.map { |k,v|
|
36
|
+
"#{k}: #{v.inspect}" }.join(', ') %>
|
37
|
+
<% else %>
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
40
|
+
|
41
|
+
<% end -%>
|
42
|
+
<% unless defined?(JRUBY_VERSION) -%>
|
29
43
|
# To use debugger
|
30
44
|
# gem 'debugger'
|
45
|
+
<% end -%>
|