Model:
class Country
include DataMapper::Resource
property :id, Serial
property :name, String
property :continent, String
end
I’m trying to do a query by the name attribute:
Country.find(:name => "value")
But it keeps returning me a nil. Which should not be the case since I’m very sure that the record with the particular value exist in the database.
I realized I have to do:
Country.first(:name => "value")orCountry.last(:name => "value")Country.getonly supports search by primary keys or composite keysAnd alternative is:
Country.all(:conditions => { :name => "value" })Reference: http://datamapper.org/docs/find.html