将变量传递给'helper_method's [英] Passing variables to 'helper_method's

查看:68
本文介绍了将变量传递给'helper_method's的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ruby on Rails 3.0.9,我想将一些变量传递给控制器​​中声明的helper_method.

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?

推荐答案

要编写函数,请执行以下操作:

To write a function you do this:

def method_name(param1,param2)

def method_name (param1,param2)

要调用一个函数,您可以执行以下操作:

to call a function you do this:

方法名(arg1,arg2)

method_name (arg1, arg2)

这篇关于将变量传递给'helper_method's的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆