Topic: More than one condition

Can somebody tell me what I'm doing wrong here? I'm getting records where the "approved" column (integer) is set to 0.

def state
        state = (params[:id])
        @statelist = Event.find(:all, :conditions => ["state = '#{state}'","approved = 1"], :order => "start ASC")
end

Re: More than one condition

All of the SQL should exist in the first element of the conditions array. The other elements of the array are for inserting variables which need to be escaped to prevent SQL injection (such as the state). Like this:

Event.find(:all, :conditions => ["state = ? AND approved = 1", state], :order => "start ASC")

Railscasts - Free Ruby on Rails Screencasts

Re: More than one condition

Thank you. That did it. Sorry for the stupid questions. Just starting out, but learning fast :-)