1

我有这个

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

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

是否可以?

4

1 回答 1

0

Rhomobile 中不存在config/routes.rb 。如果我没记错,那么它就存在于rails中。

其次,“application.rb”的工作方式类似于 Rhomobile 中的“ApplicationController”。

如果您想向现有模型添加新视图,只需将新方法(def)添加到控制器(.rb)中,并添加与新方法同名的新视图(.erb)。

假设在 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>
于 2012-12-13T11:29:16.780 回答