views:

48

answers:

2
  <%= check_box_tag('videos_count')%>

If this box is checked, the param will say "videos_count"=>"1" . In the controller I have this:

    videos_count = params[:videos_count]
  @cars = Car.paginate( :page => params[:page], :per_page => 10,  
                        :conditions => ["videos_count = ?", videos_count],  

when the box is checked I see the correct parameter in the server log, but the find returns all of the results instead of results with videos_count = 1.

A: 

Check the datatype of 'videos_count' if it's Tiny INT then following may worh. No checked though.

:conditions => ["videos_count = ?", true] 
Salil
videos_count is an integer. Manually putting in true or 1 does not work.
red
I will also add that the videos_count is a counter_cache set up in the video model.
red
put a debugger and check the values for params[:videos_count], @cars
Salil
If videos_count is an integer why are you using a checkbox?
Zachary
So the checkbox only works with a boolean datatype?
red
I created a has_vid column in the db with boolean datatype. In the view I made the box with <%= check_box_tag('has_vid', true)%>. But the find is still not recognizing the boolean condition.
red
red
A: 

What will the output for this?

:conditions => ["videos_count = ?", 1])

I think there is an issue with your table.

randika