如何在控制器(RoR)中调用方法? [英] How can I call methods within controller (RoR)?

查看:104
本文介绍了如何在控制器(RoR)中调用方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是RoR的新手,我已经玩过源代码了。但我有一个问题,我已经建立了一个'def A'创建第一个CSV文件,'def B'创建第二个CSV文件。每个'def'都有自己的按钮,但我有第三个按钮创建所有CSV(从第一个和第二个CSV文件产生输出)。



方法做到吗?

  def first_csv 
...
end

def second_csv
..
end

def all_csv
<如何调用get first和second csv>>提前感谢,



$ b

解决方案

它应该像你想象的一样简单:

  def all_csv 
first_csv
second_csv
end


I am very new to RoR and I have played around the source code. But I have a problem that I already built a 'def A' for creating first CSV file, and 'def B' for creating second CSV file. Each 'def' has its own button, but I have the third button to create all CSVs (to produce output from first and second CSV files.)

What is the possible way to do it?

def first_csv
...
end

def second_csv
..
end

def all_csv
<< how to call get first and second csv >>
end

Thanks in advance,

解决方案

It should be as simple as you imagine:

def all_csv
  first_csv
  second_csv
end

这篇关于如何在控制器(RoR)中调用方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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