Ruby on Rails Saturday, August 2, 2014

On 2 August 2014 11:50, Jaimin Pandya <lists@ruby-forum.com> wrote:
> I am using Ruby 2.0.0 and Rails 3.2.16.
>
>>>I get following error after clicking on "Add to count" button :
>
> ActionController::ActionControllerError (Cannot redirect to nil!):
>
> app/controllers/line_items_controller.rb:53:in `block (2 levels) in
> create'
>
> app/controllers/line_items_controller.rb:51:in `create'
>
> I attached code of line_items_controller.rb and full trace of error.
> please find it.
>
>>Error occur at following line as display in error:
>
> format.html { redirect_to @line_item.expensescounter } #line No:53

Sometimes error messages can be meaningful. The error says Cannot
redirect to nil, so it may be that
@line_item.expensescounter is nil.

Simple debugging can be performed using Logger.info, which inserts
into the log file (eg log/development.log), so you can confirm this by
inserting, before the problem line
Logger.info( "expensescounter is: #{@line_item.expensescounter}"

If it is nil, if you cannot see the problem, you can put additional
logs in to home in on the problem.
Also in the log file you will find useful information showing the
parameters being passed into the action.

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

No comments:

Post a Comment