Skip to content
This repository
Browse code

Remove obsolete generator

  • Loading branch information...
commit a2a4c7a1355c758dff2012d13cb1d2df6b4bc73d 1 parent d081085
Prem Sichanugrist authored April 07, 2012
5  generators/paperclip/USAGE
... ...
@@ -1,5 +0,0 @@
1  
-Usage:
2  
-
3  
-  script/generate paperclip Class attachment1 (attachment2 ...)
4  
-
5  
-This will create a migration that will add the proper columns to your class's table.
27  generators/paperclip/paperclip_generator.rb
... ...
@@ -1,27 +0,0 @@
1  
-class PaperclipGenerator < Rails::Generator::NamedBase
2  
-  attr_accessor :attachments, :migration_name
3  
-
4  
-  def initialize(args, options = {})
5  
-    super
6  
-    @class_name, @attachments = args[0], args[1..-1]
7  
-  end
8  
-
9  
-  def manifest
10  
-    file_name = generate_file_name
11  
-    @migration_name = file_name.camelize
12  
-    record do |m|
13  
-      m.migration_template "paperclip_migration.rb.erb",
14  
-                           File.join('db', 'migrate'),
15  
-                           :migration_file_name => file_name
16  
-    end
17  
-  end
18  
-
19  
-  private
20  
-
21  
-  def generate_file_name
22  
-    names = attachments.map{|a| a.underscore }
23  
-    names = names[0..-2] + ["and", names[-1]] if names.length > 1
24  
-    "add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
25  
-  end
26  
-
27  
-end
19  generators/paperclip/templates/paperclip_migration.rb.erb
... ...
@@ -1,19 +0,0 @@
1  
-class <%= migration_name %> < ActiveRecord::Migration
2  
-  def self.up
3  
-<% attachments.each do |attachment| -%>
4  
-    add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
5  
-    add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
6  
-    add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
7  
-    add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
8  
-<% end -%>
9  
-  end
10  
-
11  
-  def self.down
12  
-<% attachments.each do |attachment| -%>
13  
-    remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
14  
-    remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
15  
-    remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
16  
-    remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
17  
-<% end -%>
18  
-  end
19  
-end

0 notes on commit a2a4c7a

Please sign in to comment.
Something went wrong with that request. Please try again.