Permalink
Browse files

Made generator create better file names

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@219 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent 6c56552 commit 16b60a528130b5903f97859ea9b56d4310a94d3a jyurek committed Sep 13, 2007
Showing with 11 additions and 3 deletions.
  1. +11 −3 generators/paperclip/paperclip_generator.rb
@@ -3,17 +3,25 @@ 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}"
+ def manifest
+ file_name = generate_file_name
@migration_name = file_name.camelize
record do |m|
m.migration_template "paperclip_migration.rb",
File.join('db', 'migrate'),
:migration_file_name => file_name
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

0 comments on commit 16b60a5

Please sign in to comment.