Ruby on Rails Friday, June 8, 2018



On Saturday, 9 June 2018 02:43:13 UTC+1, jim wrote:

<snip>   
    @bottle=Bottle.all[params[:id].to_i]   #:id==0

Your error is on these lines.  ..<snip>


Yeah I got it now, thanks, I fixed all my actions


In the edit action, you should be getting the id of the bottle so you can find the bottle using

Bottle.find(params[:id])

yeah


For some weird reason, @bottle here should be defined in the edit action in your controller.  But your
edit action is empty.

actually my edit action wasn't empty, it had one line.   @bottle=Bottle.all[params[:id].to_i]     But I have fixed that now , to a line that uses the .find method Bottle.find(params[:id])   and i've fixed the other actions too, like  update.

Thanks 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b0813560-3d5c-4e3c-b9f6-21892d66bd5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment