Sha256: fdff3223539f5eacf32316c88031147b2fbb37d3541d3e77eb5de7de157fe7ce

Contents?: true

Size: 570 Bytes

Versions: 6

Compression:

Stored size: 570 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration
  def self.up
<%
  module_names = class_name.underscore.split('/')[0...-1]
-%>
<% attachment_names.each do |attachment| -%>
    create_table :<%= (module_names +[attachment.pluralize]).join("_") %> do |t|
      t.integer    :<%= class_name.underscore.tr('/', '_') %>_id
      t.string     :style
      t.binary     :file_contents
    end
<% end -%>
  end

  def self.down
<% attachment_names.each do |attachment| -%>
    drop_table :<%= (module_names +[attachment.pluralize]).join("_") %>
<% end -%>
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
paperclip_database-3.0.0 lib/generators/paperclip_database/migration/templates/migration.rb.erb
paperclip_database-2.4.0 lib/generators/paperclip_database/migration/templates/migration.rb.erb
paperclip_database-2.3.1 lib/generators/paperclip_database/migration/templates/migration.rb.erb
paperclip_database-2.3.0 lib/generators/paperclip_database/migration/templates/migration.rb.erb
paperclip_database-2.2.2 lib/generators/paperclip_database/migration/templates/migration.rb.erb
paperclip_database-2.2.1 lib/generators/paperclip_database/migration/templates/migration.rb.erb