ActiveRecord: where, find

The where method for an ActiveRecord returns an ActiveRecord::Relation which behaves like an Array for some operations, but is not one.

It returns an array so if you want a single item (say with id = 3) either use:

YourModel.find(3)

or 

YourModel.where(“id = 3”).first

More here:

http://guides.rubyonrails.org/active_record_querying.html#retrieving-a-single-object

Leave a Reply

Your email address will not be published. Required fields are marked *