开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜