chell
chell

Reputation: 7866

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?

Upvotes: 1

Views: 56

Answers (1)

fl00r
fl00r

Reputation: 83680

Participant.where(:board_id => board.id, :role => "Manager").first

Upvotes: 4

Related Questions