0

I have a rails scaffold Reviews with different fields (text input) like artist, date, venue, etc. On the form page, none of my input is being saved now after I just made a new controller/model for users. I'm able to create new users with emails and passwords using the form and they're saved, but when I try to create new reviews now, all the information is blank after I hit submit. What can be causing this? I didn't modify any of the code for the reviews controller or model after creating the users. There are now 2 migration files, one for reviews and one for users, but I didn't modify either. I did modify the application_controller.rb file to detect if a user is logged in but I don't think this would cause the issue?

I tried doing rake db:drop and rake db:create all and migrate again but the still issue occurs. Any help is appreciated, thank you.

when I hit submit this is the error I get:

> Started POST "/reviews" for 127.0.0.1 at 2014-03-30 04:50:13 -0400
Processing by ReviewsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"YzL5s5e+nT/2U3zoYtrmAT443qIn2fUMjx/MAmGoyTk=", "review"=>{"artist"=>"testArtist", "venue"=>"testVenue", "date"=>"3/30/2014", "genre"=>"Rock", "sound"=>"3", "stagePresence"=>"4", "songSelection"=>"5", "overallRating"=>"2", "comments"=>"testComment"}, "commit"=>"Create Review"}
WARNING: Can't mass-assign protected attributes for Review: artist, venue, date, genre, sound, stagePresence, songSelection, overallRating, comments
    app/controllers/reviews_controller.rb:27:in `create'
   (0.2ms)  BEGIN
  SQL (38.2ms)  INSERT INTO "reviews" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"  [["created_at", Sun, 30 Mar 2014 08:50:13 UTC +00:00], ["updated_at", Sun, 30 Mar 2014 08:50:13 UTC +00:00]]
   (8.4ms)  COMMIT
Redirected to localhost:3000/reviews/3
Benjamin Bouchet
  • 12,971
  • 2
  • 41
  • 73
parameter
  • 894
  • 2
  • 18
  • 35
  • I suspect a Unpermitted parameters problem. Please post the output of your server log after your click submit – Benjamin Bouchet Mar 30 '14 at 08:48
  • @BenjaminSinclaire I edited original post: "Can't mass-assign protected attributes for Review" edit: I think it's because I'm using this gem perhaps: http://stackoverflow.com/a/17637284/2739431 – parameter Mar 30 '14 at 08:53
  • Yes that's the source of the error. Search along in Stack overflow, your case have been answered many times. – Benjamin Bouchet Mar 30 '14 at 09:11
  • thank you for helping me figure out the cause. I'll need to look into this Strong Parameters change. – parameter Mar 30 '14 at 09:31

1 Answers1

1

My issue is from having this gem "protected_attributes" that I was using for user authentication. I guess there's a new method of doing it, found here

Community
  • 1
  • 1
parameter
  • 894
  • 2
  • 18
  • 35