0

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.

tommi
  • 6,883
  • 8
  • 37
  • 60

1 Answers1

3

I realized I have to do: Country.first(:name => "value") or Country.last(:name => "value")

Country.get only supports search by primary keys or composite keys

And alternative is: Country.all(:conditions => { :name => "value" })

Reference: http://datamapper.org/docs/find.html

tommi
  • 6,883
  • 8
  • 37
  • 60