railties 3.0.20 → 3.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +36 -49
- data/README.rdoc +2 -1
- data/guides/assets/stylesheets/fixes.css +16 -0
- data/guides/rails_guides.rb +2 -2
- data/guides/rails_guides/generator.rb +8 -3
- data/guides/rails_guides/textile_extensions.rb +4 -2
- data/guides/source/2_2_release_notes.textile +3 -3
- data/guides/source/2_3_release_notes.textile +2 -2
- data/guides/source/3_0_release_notes.textile +14 -14
- data/guides/source/action_controller_overview.textile +54 -79
- data/guides/source/action_mailer_basics.textile +39 -9
- data/guides/source/action_view_overview.textile +257 -211
- data/guides/source/active_record_basics.textile +1 -1
- data/guides/source/active_record_querying.textile +217 -27
- data/guides/source/active_record_validations_callbacks.textile +94 -25
- data/guides/source/active_support_core_extensions.textile +109 -77
- data/guides/source/ajax_on_rails.textile +15 -150
- data/guides/source/api_documentation_guidelines.textile +12 -12
- data/guides/source/association_basics.textile +74 -60
- data/guides/source/caching_with_rails.textile +59 -60
- data/guides/source/command_line.textile +46 -47
- data/guides/source/configuring.textile +55 -37
- data/guides/source/contribute.textile +7 -7
- data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
- data/guides/source/credits.html.erb +3 -3
- data/guides/source/debugging_rails_applications.textile +59 -46
- data/guides/source/form_helpers.textile +76 -31
- data/guides/source/generators.textile +39 -40
- data/guides/source/getting_started.textile +73 -94
- data/guides/source/i18n.textile +64 -58
- data/guides/source/index.html.erb +3 -3
- data/guides/source/initialization.textile +634 -3284
- data/guides/source/layout.html.erb +6 -7
- data/guides/source/layouts_and_rendering.textile +59 -60
- data/guides/source/migrations.textile +63 -59
- data/guides/source/nested_model_forms.textile +2 -2
- data/guides/source/performance_testing.textile +16 -16
- data/guides/source/plugins.textile +236 -1280
- data/guides/source/rails_application_templates.textile +37 -29
- data/guides/source/rails_on_rack.textile +4 -9
- data/guides/source/routing.textile +96 -75
- data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
- data/guides/source/security.textile +57 -30
- data/guides/source/testing.textile +26 -24
- data/guides/w3c_validator.rb +2 -2
- data/lib/rails.rb +1 -7
- data/lib/rails/application.rb +46 -76
- data/lib/rails/application/bootstrap.rb +6 -11
- data/lib/rails/application/configuration.rb +43 -40
- data/lib/rails/application/finisher.rb +16 -4
- data/lib/rails/application/railties.rb +6 -24
- data/lib/rails/application/routes_reloader.rb +45 -0
- data/lib/rails/backtrace_cleaner.rb +1 -1
- data/lib/rails/cli.rb +7 -5
- data/lib/rails/commands.rb +27 -2
- data/lib/rails/commands/application.rb +14 -1
- data/lib/rails/commands/benchmarker.rb +3 -1
- data/lib/rails/commands/dbconsole.rb +2 -2
- data/lib/rails/commands/destroy.rb +3 -1
- data/lib/rails/commands/generate.rb +3 -1
- data/lib/rails/commands/plugin.rb +2 -7
- data/lib/rails/commands/plugin_new.rb +10 -0
- data/lib/rails/commands/profiler.rb +3 -1
- data/lib/rails/commands/server.rb +4 -0
- data/lib/rails/configuration.rb +8 -81
- data/lib/rails/console/app.rb +2 -2
- data/lib/rails/engine.rb +460 -78
- data/lib/rails/engine/configuration.rb +46 -49
- data/lib/rails/engine/railties.rb +33 -0
- data/lib/rails/generators.rb +11 -5
- data/lib/rails/generators/actions.rb +2 -27
- data/lib/rails/generators/app_base.rb +216 -0
- data/lib/rails/generators/base.rb +3 -2
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +2 -1
- data/lib/rails/generators/migration.rb +6 -2
- data/lib/rails/generators/named_base.rb +79 -3
- data/lib/rails/generators/rails/app/app_generator.rb +44 -209
- data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
- data/lib/rails/generators/rails/app/templates/README +2 -2
- data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
- data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
- data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
- data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/rails/generators/rails/assets/USAGE +20 -0
- data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
- data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
- data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
- data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
- data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
- data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
- data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
- data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_case.rb +2 -20
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
- data/lib/rails/info.rb +0 -1
- data/lib/rails/paths.rb +119 -65
- data/lib/rails/plugin.rb +18 -19
- data/lib/rails/rack/log_tailer.rb +1 -1
- data/lib/rails/railtie.rb +50 -47
- data/lib/rails/railtie/configurable.rb +20 -10
- data/lib/rails/railtie/configuration.rb +20 -19
- data/lib/rails/source_annotation_extractor.rb +5 -5
- data/lib/rails/tasks.rb +1 -0
- data/lib/rails/tasks/assets.rake +10 -0
- data/lib/rails/tasks/documentation.rake +2 -8
- data/lib/rails/tasks/engine.rake +69 -0
- data/lib/rails/tasks/framework.rake +4 -21
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/routes.rake +2 -1
- data/lib/rails/test_help.rb +17 -1
- data/lib/rails/test_unit/railtie.rb +1 -1
- data/lib/rails/test_unit/testing.rake +8 -3
- data/lib/rails/version.rb +3 -3
- metadata +128 -100
- checksums.yaml +0 -7
- data/lib/rails/application/configurable.rb +0 -19
- data/lib/rails/console/sandbox.rb +0 -6
- data/lib/rails/deprecation.rb +0 -41
- data/lib/rails/engine/configurable.rb +0 -25
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
- data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
- data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
- data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
- data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
- data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
- data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
- data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
- data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
- data/lib/rails/info_routes.rb +0 -3
@@ -0,0 +1,9 @@
|
|
1
|
+
# Provide a simple gemspec so you can easily use your
|
2
|
+
# project in your rails apps through git.
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "<%= name %>"
|
5
|
+
s.summary = "Insert <%= camelized %> summary."
|
6
|
+
s.description = "Insert <%= camelized %> description."
|
7
|
+
s.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
8
|
+
s.version = "0.0.1"
|
9
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright <%= Date.today.year %> YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
11
|
+
rdoc.rdoc_dir = 'rdoc'
|
12
|
+
rdoc.title = '<%= camelized %>'
|
13
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
14
|
+
rdoc.rdoc_files.include('README.rdoc')
|
15
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
|
+
end
|
17
|
+
|
18
|
+
<% if full? && !options[:skip_active_record] -%>
|
19
|
+
APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
|
20
|
+
load 'rails/tasks/engine.rake'
|
21
|
+
<% end %>
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
<% unless options[:skip_active_record] -%>
|
4
|
+
require 'rails/all'
|
5
|
+
<% else -%>
|
6
|
+
# require "active_record/railtie"
|
7
|
+
require "action_controller/railtie"
|
8
|
+
require "action_mailer/railtie"
|
9
|
+
require "active_resource/railtie"
|
10
|
+
require "rails/test_unit/railtie"
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
Bundler.require
|
14
|
+
require "<%= name %>"
|
15
|
+
|
16
|
+
<%= application_definition %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
5
|
+
load File.expand_path('../../<%= dummy_path %>/script/rails', __FILE__)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
@@ -16,9 +16,9 @@ module Rails
|
|
16
16
|
|
17
17
|
def add_resource_route
|
18
18
|
return if options[:actions].present?
|
19
|
-
route_config =
|
19
|
+
route_config = regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
|
20
20
|
route_config << "resources :#{file_name.pluralize}"
|
21
|
-
route_config << " end" *
|
21
|
+
route_config << " end" * regular_class_path.size
|
22
22
|
route route_config
|
23
23
|
end
|
24
24
|
end
|
@@ -6,8 +6,27 @@ module Rails
|
|
6
6
|
remove_hook_for :resource_controller
|
7
7
|
remove_class_option :actions
|
8
8
|
|
9
|
+
class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets"
|
10
|
+
class_option :stylesheet_engine, :desc => "Engine for stylesheets"
|
11
|
+
|
9
12
|
hook_for :scaffold_controller, :required => true
|
10
|
-
|
13
|
+
|
14
|
+
def copy_stylesheets_file
|
15
|
+
if behavior == :invoke && options.stylesheets?
|
16
|
+
template "scaffold.#{stylesheet_extension}", "app/assets/stylesheets/scaffold.#{stylesheet_extension}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
hook_for :assets do |assets|
|
21
|
+
invoke assets, [controller_name]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def stylesheet_extension
|
27
|
+
options.stylesheet_engine.present? ?
|
28
|
+
"css.#{options.stylesheet_engine}" : "css"
|
29
|
+
end
|
11
30
|
end
|
12
31
|
end
|
13
32
|
end
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a {
|
16
|
+
color: #000;
|
17
|
+
&:visited { color: #666; }
|
18
|
+
&:hover { color: #fff; background-color:#000; }
|
19
|
+
}
|
20
|
+
|
21
|
+
div.field, div.actions {
|
22
|
+
margin-bottom: 10px;
|
23
|
+
}
|
24
|
+
|
25
|
+
#notice {
|
26
|
+
color: green;
|
27
|
+
}
|
28
|
+
|
29
|
+
.field_with_errors {
|
30
|
+
padding: 2px;
|
31
|
+
background-color: red;
|
32
|
+
display: table;
|
33
|
+
}
|
34
|
+
|
35
|
+
#error_explanation {
|
36
|
+
width: 450px;
|
37
|
+
border: 2px solid red;
|
38
|
+
padding: 7px;
|
39
|
+
padding-bottom: 0;
|
40
|
+
margin-bottom: 20px;
|
41
|
+
background-color: #f0f0f0;
|
42
|
+
|
43
|
+
h2 {
|
44
|
+
text-align: left;
|
45
|
+
font-weight: bold;
|
46
|
+
padding: 5px 5px 5px 15px;
|
47
|
+
font-size: 12px;
|
48
|
+
margin: -7px;
|
49
|
+
margin-bottom: 0px;
|
50
|
+
background-color: #c00;
|
51
|
+
color: #fff;
|
52
|
+
}
|
53
|
+
|
54
|
+
ul li {
|
55
|
+
font-size: 12px;
|
56
|
+
list-style: square;
|
57
|
+
}
|
58
|
+
}
|
@@ -1,34 +1,35 @@
|
|
1
|
+
<% module_namespacing do -%>
|
1
2
|
class <%= controller_class_name %>Controller < ApplicationController
|
2
3
|
# GET <%= route_url %>
|
3
|
-
# GET <%= route_url %>.
|
4
|
+
# GET <%= route_url %>.json
|
4
5
|
def index
|
5
6
|
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
6
7
|
|
7
8
|
respond_to do |format|
|
8
9
|
format.html # index.html.erb
|
9
|
-
format.
|
10
|
+
format.json { render <%= key_value :json, "@#{plural_table_name}" %> }
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
# GET <%= route_url %>/1
|
14
|
-
# GET <%= route_url %>/1.
|
15
|
+
# GET <%= route_url %>/1.json
|
15
16
|
def show
|
16
17
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
17
18
|
|
18
19
|
respond_to do |format|
|
19
20
|
format.html # show.html.erb
|
20
|
-
format.
|
21
|
+
format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
# GET <%= route_url %>/new
|
25
|
-
# GET <%= route_url %>/new.
|
26
|
+
# GET <%= route_url %>/new.json
|
26
27
|
def new
|
27
28
|
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
28
29
|
|
29
30
|
respond_to do |format|
|
30
31
|
format.html # new.html.erb
|
31
|
-
format.
|
32
|
+
format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -38,46 +39,47 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
38
39
|
end
|
39
40
|
|
40
41
|
# POST <%= route_url %>
|
41
|
-
# POST <%= route_url %>.
|
42
|
+
# POST <%= route_url %>.json
|
42
43
|
def create
|
43
44
|
@<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
|
44
45
|
|
45
46
|
respond_to do |format|
|
46
47
|
if @<%= orm_instance.save %>
|
47
|
-
format.html { redirect_to
|
48
|
-
format.
|
48
|
+
format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
|
49
|
+
format.json { render <%= key_value :json, "@#{singular_table_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, "@#{singular_table_name}" %> }
|
49
50
|
else
|
50
|
-
format.html { render :action
|
51
|
-
format.
|
51
|
+
format.html { render <%= key_value :action, '"new"' %> }
|
52
|
+
format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
57
|
# PUT <%= route_url %>/1
|
57
|
-
# PUT <%= route_url %>/1.
|
58
|
+
# PUT <%= route_url %>/1.json
|
58
59
|
def update
|
59
60
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
60
61
|
|
61
62
|
respond_to do |format|
|
62
63
|
if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
|
63
|
-
format.html { redirect_to
|
64
|
-
format.
|
64
|
+
format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
|
65
|
+
format.json { head :ok }
|
65
66
|
else
|
66
|
-
format.html { render :action
|
67
|
-
format.
|
67
|
+
format.html { render <%= key_value :action, '"edit"' %> }
|
68
|
+
format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
73
|
# DELETE <%= route_url %>/1
|
73
|
-
# DELETE <%= route_url %>/1.
|
74
|
+
# DELETE <%= route_url %>/1.json
|
74
75
|
def destroy
|
75
76
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
76
77
|
@<%= orm_instance.destroy %>
|
77
78
|
|
78
79
|
respond_to do |format|
|
79
|
-
format.html { redirect_to
|
80
|
-
format.
|
80
|
+
format.html { redirect_to <%= index_helper %>_url }
|
81
|
+
format.json { head :ok }
|
81
82
|
end
|
82
83
|
end
|
83
84
|
end
|
85
|
+
<% end -%>
|
@@ -34,7 +34,7 @@ module Rails
|
|
34
34
|
attr_reader :controller_name
|
35
35
|
|
36
36
|
def controller_class_path
|
37
|
-
|
37
|
+
class_path
|
38
38
|
end
|
39
39
|
|
40
40
|
def controller_file_name
|
@@ -46,14 +46,14 @@ module Rails
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def controller_class_name
|
49
|
-
|
49
|
+
(controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::')
|
50
50
|
end
|
51
51
|
|
52
52
|
def controller_i18n_scope
|
53
53
|
@controller_i18n_scope ||= controller_file_path.gsub('/', '.')
|
54
54
|
end
|
55
55
|
|
56
|
-
# Loads the ORM::Generators::ActiveModel class. This class is
|
56
|
+
# Loads the ORM::Generators::ActiveModel class. This class is responsible
|
57
57
|
# to tell scaffold entities how to generate an specific method for the
|
58
58
|
# ORM. Check Rails::Generators::ActiveModel for more information.
|
59
59
|
def orm_class
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute'
|
2
2
|
require 'active_support/core_ext/module/delegation'
|
3
3
|
require 'active_support/core_ext/hash/reverse_merge'
|
4
|
+
require 'active_support/core_ext/kernel/reporting'
|
4
5
|
require 'rails/generators'
|
5
6
|
require 'fileutils'
|
6
7
|
|
@@ -65,25 +66,6 @@ module Rails
|
|
65
66
|
self.destination_root = path
|
66
67
|
end
|
67
68
|
|
68
|
-
# Captures the given stream and returns it:
|
69
|
-
#
|
70
|
-
# stream = capture(:stdout){ puts "Cool" }
|
71
|
-
# stream # => "Cool\n"
|
72
|
-
#
|
73
|
-
def capture(stream)
|
74
|
-
begin
|
75
|
-
stream = stream.to_s
|
76
|
-
eval "$#{stream} = StringIO.new"
|
77
|
-
yield
|
78
|
-
result = eval("$#{stream}").string
|
79
|
-
ensure
|
80
|
-
eval("$#{stream} = #{stream.upcase}")
|
81
|
-
end
|
82
|
-
|
83
|
-
result
|
84
|
-
end
|
85
|
-
alias :silence :capture
|
86
|
-
|
87
69
|
# Asserts a given file exists. You need to supply an absolute path or a path relative
|
88
70
|
# to the configured destination:
|
89
71
|
#
|
@@ -132,7 +114,7 @@ module Rails
|
|
132
114
|
end
|
133
115
|
alias :assert_no_directory :assert_no_file
|
134
116
|
|
135
|
-
# Asserts a given
|
117
|
+
# Asserts a given migration exists. You need to supply an absolute path or a
|
136
118
|
# path relative to the configured destination:
|
137
119
|
#
|
138
120
|
# assert_migration "db/migrate/create_products.rb"
|