i am incredibly new to Rails and am completely stumped. I really just need this too work as it is part of another larger mostly Javascript project, and the Rails portion just got dumped on me. I had to add columns to the page_events table (columns added were student_id, student_name, and survey_name) so i did the migrations, rake db:migrate, everything went smoothly. here is the relevant portion of my schema.db
create_table "page_events", :force => true do |t|
t.string "page"
t.integer "num_focus", :default => 0
t.integer "num_distracted", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "time_focused", :default => 0
t.integer "time_distracted", :default => 0
t.integer "total_time", :default => 0
t.string "session_id"
t.string "student_id"
t.string "student_name"
t.string "survey_name"
end
however when i try to post data to the page_events page, the server responds with 500 internal server error
ActiveRecord::UnknowAttributeError (unknown attribute: student_id):app/controllers/page_events_controller.rb:51 in 'new'
i tried posting the data, except without the student_name, student_id, or survey_name and it worked fine. no 500 error and the data that i sent showed up on the page_events index like it is supposed to. I checked all over and cant find anything conclusive on this and im very nervous to break it because as i said im very new to Rails. i saw that some suggestions were to regenerate the model and such but i dont know if that will help. the only place i can find in the code with explicit table names and columns is in schema.db and as posted above, seems to be correct. please help...
i am deploying to a heroku app, i dont know if that makes a difference...
After you've done a migration you need to do a heroku restart
since the application is running in production mode and will have cached the db schema BEFORE the migration was run. Restarting the application will recache the schema. Chances are though, that your application has already been restarted by Heroku since you posted this and the problem has now gone away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With