Passing variables to 'helper_method's

≯℡__Kan透↙ 提交于 2019-12-11 14:12:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!