I am trying to follow a tutorial from Adding a 5 star ratings feature to a Rails 4 model made by @Simpleton and I cannot successfully create the model for the tutorial.
When I type rails g model Rating comment:references user:references score:integer default: 0
it will create the model. When I run rake db:migrate
I receive an error message which says:
/db/migrate/20140107143726_create_ratings.rb:8: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
What can I do? Is there a different way to set the default value for the integer named "score"?
Update
In "db/migrate/20140107143726_create_ratings.rb" I have:
class CreateRatings < ActiveRecord::Migration
def change
create_table :ratings do |t|
t.references :review, index: true
t.references :user, index: true
t.integer :score
t.string :default
t.string :0
t.timestamps
end
end
end
*I changed comment to review
Would this work?
class CreateRatings < ActiveRecord::Migration
def change
create_table :ratings do |t|
t.references :review, index: true
t.references :user, index: true
t.integer :score, :default => 0
t.timestamps
end
end
end