DEV Community


Discussion on: Day 80 - #100DaysofCode - Stuck On A Rails Problem

sowenjub profile image
Arnaud Joubay

There are many things going on here, but here are a few pointers.

<%= check_box_tag "photo_ids[]", p , true%>
should be
<%= check_box_tag "photo_ids[]", , true%>
The id that will be returned here being the Unsplash photo id.

Second, since you used p, what you receive in the params[:photo_ids] is an array of strings. Even though it looks like the fingerprint of the object, it's not the object anymore but its fingerprint.
So when you call params[:photo_ids][1].save, you're calling save on a string (the string representation of the object, "#Photo:0x00007f961bb58278").
Hence the error NoMethodError Exception: undefined methodsave' for "#Photo:0x00007f961bb58278":Stringwhich tells you that there is nosave` method for String objects.