Commit 16b60a52 by jyurek

Made generator create better file names

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@219 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent 6c56552b
......@@ -3,11 +3,11 @@ class PaperclipGenerator < Rails::Generator::NamedBase
def initialize(args, options = {})
super
@class_name, @attachments = args
@class_name, @attachments = args[0], args[1..-1]
end
def manifest
file_name = "add_paperclip_attachment_columns_to_#{@class_name.underscore}"
file_name = generate_file_name
@migration_name = file_name.camelize
record do |m|
m.migration_template "paperclip_migration.rb",
......@@ -16,4 +16,12 @@ class PaperclipGenerator < Rails::Generator::NamedBase
end
end
private
def generate_file_name
names = attachments.map{|a| a.underscore }
names = names[0..-2] + ["and", names[-1]] if names.length > 1
"add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment