Commit 0a90942f by jyurek

Fixes to the generator

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@213 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent f5d800b5
class PaperclipGenerator < Rails::Generator::NamedBase
attr_accessor :attachments
attr_accessor :attachments, :migration_name
def initialize(*args)
super(*args)
@attachments = args
def initialize(args, options = {})
super
@class_name, @attachments = args
end
def manifest
file_name = "add_paperclip_attachment_columns_to_#{@class_name.underscore.camelize}"
@migration_name = file_name.camelize
record do |m|
m.migration_template "paperclip_migration.rb", File.join('db', 'migrate')
m.migration_template "paperclip_migration.rb",
File.join('db', 'migrate'),
:migration_file_name => file_name
end
end
......
class AddPaperclipAttachmentColumnsTo<%= class_name.underscore.camelize %> < ActiveRecord::Migration
class <%= migration_name %> < ActiveRecord::Migration
def self.up
<% attachments.each do |attachment| -%>
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
......
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