- I have a model called “Notes”.
- The attributes are “id”, “url”, “content”.
- In my notes_controller want to retrieve the “id” of a particular note where the “url” matches my query url.
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?
Try
@noteid = Note.where(:url => "blah").select('id').id