diff options
Diffstat (limited to 'railties')
9 files changed, 3 insertions, 51 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 41aecea355..8794392a7d 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -50,7 +50,6 @@ module Rails :performance_tool => nil, :resource_controller => :controller, :scaffold_controller => :scaffold_controller, - :singleton => false, :stylesheets => true, :test_framework => nil, :template_engine => :erb @@ -334,4 +333,4 @@ module Rails paths end end -end
\ No newline at end of file +end diff --git a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb index 2db7f7bbf3..b2c8d7051b 100644 --- a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb @@ -8,17 +8,12 @@ module Erb argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" - class_option :singleton, :type => :boolean, :desc => "Supply to skip index view" - def create_root_folder empty_directory File.join("app/views", controller_file_path) end def copy_view_files - views = available_views - views.delete("index") if options[:singleton] - - views.each do |view| + available_views.each do |view| filename = filename_with_extensions(view) template filename, File.join("app/views", controller_file_path, filename) end diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb index ee302b8aad..fc070026d6 100644 --- a/railties/lib/rails/generators/rails/resource/resource_generator.rb +++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb @@ -14,26 +14,13 @@ module Rails class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [], :desc => "Actions for the resource controller" - class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" - def add_resource_route return if options[:actions].present? route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ") - route_config << "resource#{:s unless options[:singleton]} :#{pluralize?(file_name)}" + route_config << "resources :#{file_name.pluralize}" route_config << " end" * class_path.size route route_config end - - protected - - def pluralize?(name) - if options[:singleton] - name - else - name.pluralize - end - end - end end end diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb index 49af2974cd..2271c6f9c1 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -10,8 +10,6 @@ module Rails class_option :orm, :banner => "NAME", :type => :string, :required => true, :desc => "ORM to generate the controller for" - class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" - def create_controller_files template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") end diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 84cf58d7c4..b21340f755 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -1,5 +1,4 @@ class <%= controller_class_name %>Controller < ApplicationController -<% unless options[:singleton] -%> # GET <%= route_url %> # GET <%= route_url %>.xml def index @@ -10,7 +9,6 @@ class <%= controller_class_name %>Controller < ApplicationController format.xml { render :xml => @<%= plural_table_name %> } end end -<% end -%> # GET <%= route_url %>/1 # GET <%= route_url %>/1.xml diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index c0315c7fe6..f7e907a017 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -6,7 +6,6 @@ module TestUnit class ScaffoldGenerator < Base include Rails::Generators::ResourceHelpers - class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" check_class_collision :suffix => "ControllerTest" def create_test_files diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb index 957ebaa522..f23e495450 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb @@ -5,13 +5,11 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase @<%= singular_table_name %> = <%= table_name %>(:one) end -<% unless options[:singleton] -%> test "should get index" do get :index assert_response :success assert_not_nil assigns(:<%= table_name %>) end -<% end -%> test "should get new" do get :new diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 96fd7a0a72..55d5bd6f83 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -59,14 +59,6 @@ class ResourceGeneratorTest < Rails::Generators::TestCase end end - def test_singleton_resource - run_generator ["account", "--singleton"] - - assert_file "config/routes.rb" do |route| - assert_match /resource :account$/, route - end - end - def test_plural_names_are_singularized content = run_generator ["accounts".freeze] assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/ diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 8040b22fe6..d55ed22975 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -78,20 +78,6 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase end end - def test_generates_singleton_controller - run_generator ["User", "name:string", "age:integer", "--singleton"] - - assert_file "app/controllers/users_controller.rb" do |content| - assert_no_match /def index/, content - end - - assert_file "test/functional/users_controller_test.rb" do |content| - assert_no_match /test "should get index"/, content - end - - assert_no_file "app/views/users/index.html.erb" - end - def test_skip_helper_if_required run_generator ["User", "name:string", "age:integer", "--no-helper"] assert_no_file "app/helpers/users_helper.rb" |