i have to fine those article which have state id 3 OR 4 and skill_id = params[:browsed_by_skill]
@articles = Article.find(:all,:conditions => ["state = ? AND skill_id = ? ", [‘3’, ‘4’], params[:browsed_by_skill]])
Getting error this
Mysql::Error: Operand should contain 1 column(s): SELECT `articles`.* FROM `articles` WHERE (state = '3','4' AND skill_id = '5' )
any suggetions ,
THanks in advance
solved
@articles = Article.find(:all,:conditions => ["state in (?) AND skill_id = ? ", [‘3’, ‘4’], params[:browsed_by_skill]])
Thanks
solved
@articles = Article.find(:all,:conditions => ["state in (?) AND skill_id = ? ", [‘3’, ‘4’], params[:browsed_by_skill]])
Thanks
you can do
states = [‘3’, ‘4’]
skill_id = params[:browsed_by_skill]
Article.where(;state => states, :skill_id => skill_id)
states in the above code can be a range or an array or a single integer.