Ruby on Rails Thursday, April 28, 2011

wondering if there is a way to do this..

say we have a model that has attributes length and width..

:length and :width

and we have a class square:

class Square < ActiveRecord::Base

def area
area = length * width
end

end

is there a way i can do a:

Square.find(:area => '144')

to produce any squares with an area of 144?

i know there are lots of other ways to do this, but in the case i am
working on, a find would be REALLY clean..

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment