I have this in my db/schema.rb
:
create_table "bank", :force => true do |t|
t.string "name", 开发者_StackOverflow :null => false
t.string "identifier", :null => false
t.timestamp "created_at", :null => false
t.timestamp "updated_at", :null => false
end
Is there an easy way for me to create a model based on this? I would hate to have to manually type
rails generate model Bank name:string identifier:string
because I have about 40 tables in my database, many having many more columns than this.
Is this possible?
Are you trying to backtrace to getting models & migrations out of an existing db/schema.rb
?
schema.rb
should be the result of your migrations, and you really don't need do do anything for the models, as all you need to do is create a class that inherits from ActiveRecord::Base
.
In other words, specifying columns in rails generate model Bank name:string identifier:string
simply creates the migration for you, there's no notion of these attributes in the model file.
精彩评论