0

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
2
  • Please, paste your last migration or the failing migration Commented Feb 4, 2016 at 16:55
  • I have added the failing migration, it's the only one I've done yet. Commented Feb 4, 2016 at 17:08

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Hey hey! That's it. Thanks, I'm super new to Rails so this is pretty basic but I appreciate it I was really stuck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.