Similar questions have been asked but none of the recommendations have worked for me. I'm trying to migrate a db in rails development on my computer and I keep getting this error message:
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined local variable or method `total' for #<CreateProfessors:0x007f8ce3ca4e60>/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:664:in `block in method_missing'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord- 4.2.5.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:634:in `say_with_time'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:654:in `method_missing'
It continues on for a hundred lines or so.
One of the posts here recommended removing
null: false
from
t.timestamps null:false
which I did.
Another recommendation I have tried is running db:drop:all then db:create:all then db:migrate.
To make sure sqlite3 was on my OSX I ran a sqlite3 query in terminal and was returned: SQLite version 3.8.10.2 so I assume that's working properly.
Failing migration:
class CreateProfessors < ActiveRecord::Migration
def change
create_table :professors do |t|
t.string :fname
t.string :lname
t.decimal :rating-total
t.decimal :rating-hw
t.decimal :rating-test
t.decimal :rating-interest
t.text :comments
t.string :ease
t.timestamps
end
end
end
These column names are illegal:
t.decimal :rating-total
t.decimal :rating-hw
t.decimal :rating-test
t.decimal :rating-interest
It should be: (use _
instead of -
)
t.decimal :rating_total
t.decimal :rating_hw
t.decimal :rating_test
t.decimal :rating_interest