Displaying 2 results from an estimated 2 matches for "all_rating".
Did you mean:
all_ratings
2012 Oct 21
2
check box tag binding between controller and the view
I am new to RoR. The problem i am facing is that that i have a few check
box and initially when i run my app for the first time i want them all
to be selected while for every next time i want it to have the last
checked boxes checked. To do this, In my controller i have
@all_ratings = Movie.all_ratings
@selected_ratings = []
if !params[:ratings].nil?
params[:ratings].each_key do |key|
@selected_ratings << key
end
elsif
@selected_ratings = @all_ratings
end
While my model looks something like
class Movie < ActiveR...
2012 Oct 21
5
Error occured while evaluating nil
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.<<
--
Posted via http://www.ruby-forum.com/.
--
You received...