Sha256: 5160615ff6655ebcffa146725965da428f9d37c310510975b637c716943b05e5
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
class Create<%= class_name.pluralize %> < ActiveRecord::Migration def self.up create_table :refinery_<%= table_name %> do |t| <% attributes.each do |attribute| # turn image or resource into what it was supposed to be which is an integer reference to an image or resource. if attribute.type.to_s =~ /^(image|resource)$/ attribute.type = 'integer' attribute.name = "#{attribute.name}_id".gsub("_id_id", "_id") elsif attribute.type.to_s =~ /^(radio|select)$/ attribute.type = 'string' elsif attribute.type.to_s =~ /^(checkbox)$/ attribute.type = 'boolean' end -%> t.<%= attribute.type %> :<%= attribute.name %> <% end -%> t.timestamps end add_index :refinery_<%= table_name %>, :id if (seed = Rails.root.join('db', 'seeds', '<%= plural_name %>.rb')).exist? load(seed) end end def self.down if defined?(::Refinery::UserPlugin) ::Refinery::UserPlugin.destroy_all({:name => "<%= plural_name %>"}) end if defined?(::Refinery::Page) ::Refinery::Page.delete_all({:link_url => "/<%= plural_name %>"}) end drop_table :refinery_<%= table_name %> end end
Version data entries
6 entries across 6 versions & 1 rubygems