Writing query with new 'where'
I am trying to do a simple query with Rails 3 where clause开发者_开发百科.
I have the following:
Participant.find(:first, :conditions => ["participants.role = ? AND participants.board_id = ?", "Manager", board.id])
Which works very well. I am trying to rewrite it the Rails 3 way as follows:
Participant.where(:board => board, :role => "Manager")
However this does not work. Is there a way to stipulate first with the where to get the same return as above?
Participant.where(:board_id => board.id, :role => "Manager").first
精彩评论