I have a general question about Rails controller or instance method.
Say, I have two models,
Give
Take
Each of these has an identical set of columns like,
Give : weight:integer, day:date
Take: weight:integer, day:date
When @give = Give.new is created, I want to search if there is a
counterpart, Take, having the same values, weight and day. So I need to
define a search method somewhere.
I believe it will look like
@give = Give.new
...
if @give.search_counter #<- returns true if the counterpart exists
...
else
end
This must work for Take as well
@take = Take.new
...
if @take.search_counter #<- returns true if the counterpart exists
...
else
end
Questions:
Is it possible? I am not sure if the method works without arguments...
Where do I have to define the method? application_controller.rb maybe?
soichi
--
Posted via
http://www.ruby-forum.com/.