I have created a migration file as follows before generating a model , viewer or a controller
class Papaers < ActiveRecord::Migration
def self.up
create_table :papers do |t|
t.integer :unit_id, :null=>false
t.integer :document_id, :null=>false
t.timestamps
end
end
def self.down
drop_table :papers
end
end
This ran well and it create the table. But now I want to create a model for this table. Is there a way in rails to create a model after running migration files? I could not see any model generated under papers in model.
rails g model Papaers --migration=false
Or you can also give
rails g model Papaers
Rails generator would not overwrite if migration already exists.
rails g model Papaers --skip-migration
The --skip-migration
flag can also be used to generate a model without generating the migration file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With