Skip to content

Instantly share code, notes, and snippets.

@wichopy
Created March 17, 2017 16:14
Show Gist options
  • Save wichopy/948547aed05d6191f367631abc0959dc to your computer and use it in GitHub Desktop.
Save wichopy/948547aed05d6191f367631abc0959dc to your computer and use it in GitHub Desktop.
Create new model, migration and manually insert data.
command to insert:
r = Rating.create :user_id => 1, :product_id => 1, :description => 'I dont like this shirt', :rating => 2
To run migration:
bin/rake db:migrate
To create anew migration for adding in reference columns :
bin/rails generate migration AddUserAndProductToRatings user:references product:references
Create a new model/migration
bin/rails generate model Rating description:text rating:integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment