问题
I am using Ruby on Rails 3.0.9 and I would like to pass some variables to an helper_method stated in my controller.
class ArticlesController < ApplicationController
helper_method :method_name
private
def method_name # Here I would like to state\use something like 'def method_name(var1, var2)'
...
end
end
Is it possible? If so, how should I code and how can I use that?
回答1:
To write a function you do this:
def method_name (param1,param2)
to call a function you do this:
method_name (arg1, arg2)
来源:https://stackoverflow.com/questions/6827069/passing-variables-to-helper-methods