문제

Very simple task but I'm confused...

For example I've the class:

class Test
  include DataMapper::Resource
  property :id, Serial
  property :val1, Integer
  property :val2, Integer
end

Is it possible to find all records where val1 = val2 calling Datamapper's #all method?

The

Test.all(:val1 => :val2)

obviously doesn't work.

I want to find solution via #all without direct SQL-query like

repository(:default).adapter.select('SELECT * FROM tests WHERE val1 = val2;')
도움이 되었습니까?

해결책

You could try something like this:

Test.all(:conditions => ['val1 = val2'])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top