How to create a model after migration to rails

I created the migration file as follows before creating the model, view, or 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 works well and creates a table. But now I want to create a model for this table. Is there a way to create a model in rails after running the migration files? I could not see any model created under the documents in the model.

+4
source share
2 answers

rails g model Papaers --migration=false

Or you can also give

rails g model Papaers

The Rails generator will not be overwritten if the migration already exists.

+7
source
rails g model Papaers --skip-migration

The flag --skip-migrationcan also be used to create a model without creating a migration file.

0
source

All Articles