Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 16b60a528130b5903f97859ea9b56d4310a94d3a 1 parent 6c56552
jyurek authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 generators/paperclip/paperclip_generator.rb
View
14 generators/paperclip/paperclip_generator.rb
@@ -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}"
+ def manifest
+ file_name = generate_file_name
@migration_name = file_name.camelize
record do |m|
m.migration_template "paperclip_migration.rb",
@@ -15,5 +15,13 @@ def manifest
: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
Please sign in to comment.
Something went wrong with that request. Please try again.