Sunday, October 21, 2012

Re: [Rails] Error occured while evaluating nil

On 21 October 2012 16:20, Muhammad Salman <lists@ruby-forum.com> wrote:
> This is the code
>
> if !params[:ratings].nil?
> params[:ratings].each_key do |r|
> @selected_ratings << r
> @movies << Movie.where('rating = :rating', :rating => r)
> @sort = params[:sort]
> end
> elsif
> @selected_ratings = @all_ratings
> @movies = Movie.order(@sort)
> @sort = params[:sort]
> end
>
> This is the error
>
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.<<

The clue is often in the error message, it is worth reading it carefully.
It is saying that you have something << where the something is nil.
You have not told us which line it is failing on, but presumably it is
either @selected_ratings or @movies. What are they set to before the
lines you have shown us?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate