aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/named_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/named_base.rb')
-rw-r--r--railties/lib/rails/generators/named_base.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 84f8f76838..e712c747b0 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -18,6 +18,8 @@ module Rails
parse_attributes! if respond_to?(:attributes)
end
+ # Defines the template that would be used for the migration file.
+ # The arguments include the source template file, the migration filename etc.
no_tasks do
def template(source, *args, &block)
inside_template do
@@ -40,7 +42,7 @@ module Rails
def indent(content, multiplier = 2)
spaces = " " * multiplier
- content = content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
+ content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
end
def wrap_with_namespace(content)
@@ -160,6 +162,14 @@ module Rails
end
end
+ def attributes_names
+ @attributes_names ||= attributes.each_with_object([]) do |a, names|
+ names << a.column_name
+ names << 'password_confirmation' if a.password_digest?
+ names << "#{a.name}_type" if a.polymorphic?
+ end
+ end
+
def pluralize_table_names?
!defined?(ActiveRecord::Base) || ActiveRecord::Base.pluralize_table_names
end
@@ -169,10 +179,10 @@ module Rails
#
# ==== Examples
#
- # check_class_collision suffix: "Observer"
+ # check_class_collision suffix: "Decorator"
#
# If the generator is invoked with class name Admin, it will check for
- # the presence of "AdminObserver".
+ # the presence of "AdminDecorator".
#
def self.check_class_collision(options={})
define_method :check_class_collision do