Ruby on Rails Thursday, March 5, 2015

On 5 March 2015 at 14:56, Deepak Sharma <deeky.sharma@gmail.com> wrote:

> NoMethodError (undefined method `[]' for nil:NilClass):
> app/controllers/pages_controller.rb:9:in `save_page'
>
> This is my controller file pages_controller,rb for save_page
>
> def save_page
> page = Page.find(params[:id])
> page.title = params[:content][:page_title][:value]
> page.content = params[:content][:page_content][:value]

You have not told us which is line 9 but presumably it is one of the
above. Have a look in the log file to see what params is for the
request and check that it has the contents referenced above
(page_title and page_content and each of those has :value).

Colin

--
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/CAL%3D0gLv_gJxxUXeaWjYG0dGfM1fvyYO2S25eciR%3DhtGPM5G0Ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment