Answer the question
In order to leave comments, you need to log in
How can I make a common view for all controller methods?
There is a controller:
def campaigns
get_calculate_stats(Campaign)
render 'stats'
end
def sources
get_calculate_stats(Source)
render 'stats'
end
def offers
get_calculate_stats(Offer)
render 'stats'
end
Answer the question
In order to leave comments, you need to log in
module Bar
%w{one two three}.each do |n|
define_method n do
super()
print " BAR"
end
end
end
class Foo
prepend Bar
def one
print '1'
end
def two
print '2'
end
def three
print '3'
end
end
Foo.new.one # 1 BAR
Foo.new.two # 2 BAR
Foo.new.three # 3 BAR
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question