rgoraya
rgoraya

Reputation: 241

Rails 3 finding a record based on non-key attribute

I am using the following:

    @noteid = Note.find(:url => "blah").id

However, this returns the error: Unknown key(s): url

is there a way to find a record based on non-key attributes?

Upvotes: 0

Views: 1551

Answers (1)

Reuben Mallaby
Reuben Mallaby

Reputation: 5767

Try @noteid = Note.where(:url => "blah").select('id').id

Upvotes: 7

Related Questions