diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 17 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/routes.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/tasks/documentation.rake | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 50e7aa85ac..25d0161e4c 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -1,6 +1,4 @@ require 'active_support/time' -require 'active_support/core_ext/object/inclusion' -require 'active_support/core_ext/object/blank' module Rails module Generators @@ -21,15 +19,20 @@ module Rails has_index, type = type, nil if INDEX_OPTIONS.include?(type) type, attr_options = *parse_type_and_options(type) + type = type.to_sym if type - if type.in?(%w(references belongs_to)) - references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? {:unique => true} : true - attr_options.merge!({:index => references_index}) + if type && reference?(type) + references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { :unique => true } : true + attr_options[:index] = references_index end new(name, type, has_index, attr_options) end + def reference?(type) + [:references, :belongs_to].include? type + end + private # parse possible attribute options like :limit for string/text/binary/integer or :precision/:scale for decimals @@ -48,7 +51,7 @@ module Rails def initialize(name, type=nil, index_type=false, attr_options={}) @name = name - @type = (type.presence || :string).to_sym + @type = type || :string @has_index = INDEX_OPTIONS.include?(index_type) @has_uniq_index = UNIQ_INDEX_OPTIONS.include?(index_type) @attr_options = attr_options @@ -93,7 +96,7 @@ module Rails end def reference? - self.type.in?(:references, :belongs_to) + self.class.reference?(type) end def has_index? diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb index ea81748464..24026cf324 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb @@ -3,11 +3,11 @@ # first created -> highest priority. # Sample of regular route: - # match 'products/:id' => 'catalog#view' + # get 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # get 'products/:id/purchase' => 'catalog#purchase', :as => :purchase # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): @@ -52,7 +52,4 @@ # See how all your routes lay out with "rake routes" - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id))(.:format)' end diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 2851ca4189..4ec49eee76 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -2,7 +2,7 @@ require 'rdoc/task' # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise class RDocTaskWithoutDescriptions < RDoc::Task - include ::Rake::DSL + include ::Rake::DSL if defined?(::Rake::DSL) def define task rdoc_task_name |