Chaining your own method in Ruby on Rails
- by steven_noble
In my Rails app, I am used to using syntax like the following in a number of places, including helpers/application_helper.rb:
def my_method(x,y)
return x+y
end
I am also used to calling the resulting method from basically anywhere in my app using syntax like this:
my_method(2,3)
However, I'd like to be able to use syntax like like this:
class_from_my_rails_app.my_method(3)
How and where do I define my_method so I can use it like this?
I'm happy to consult the documentation, but I just don't know what the latter style is called. What do you call it?
Many thanks,
Steven.