在rhomobile控制器中添加新视图

时间:2012-12-11 09:33:26

标签: ruby rhomobile rhodes

我有this

我在哪里可以找到config/routes.rb以及如何在Rhomobile中使用ApplicationController

如何将视图添加到现有的rhomobile控制器?

有可能吗?

1 个答案:

答案 0 :(得分:0)

Rhomobile中不存在

config / routes.rb 。如果我没有错,那么它就存在于轨道中。

其次,“application.rb”与Rhomobile中的“ApplicationController”类似。

如果您想要向现有模型添加新视图,只需将新方法(def)添加到控制器(.rb)和新视图(.erb)中,其名称与新方法相同。 / p>

假设在app / Demo中存在一个模型DemoController.rb。您可以像

一样添加新方法
class DemoController < Rho::RhoController
  ...
  def index
  end

  def new_method
  end

end

要从索引视图导航到new_method,您可以编写

<button onclick="location.href='/app/Demo/new_method'">new method</button>

<button onclick="location.href='<%= url_for :action => :new_method %>'"
>new method</button>