Hello,
I have this class in my Rails project :
class CreateModels < ActiveRecord::Migration
def self.up
create_table :models do |t|
t.string :model, :default => "Model", :limit => 10
t.string :description, :default => "short Description", :limit => 20
t.string :longdescription, :default => "long Description", :limit => 40
t.timestamps
end
end
def self.down
drop_table :models
end
end
Now, if I need the same fields in another table, I need to put again :
.
.
t.string :description, :default => "short Description", :limit => 20
t.string :longdescription, :default => "long Description", :limit => 40
.
.
How can I create something like a "template" or "pattern" that includes for
example ":default => "short Description", :limit => 20", then I only use this
template to create the new table. Something like this :
.
.
t.Template2 :description, # 'Template2' includes ":default => "short
Description", :limit => 20"
t.Template3 :longdescription, # 'Template3' includes ":default => "long
Description", :limit => 40"
.
.
Then I will use this new type to create new fields with the same
characteristics in all the tables.
Thanks,
Jose.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---