简体   繁体   English

重定向到另一个模型的索引操作,从而查看index.erb-Rhomobile

[英]Redirect to another model's index action, and hence view index.erb - Rhomobile

I am developing a Rhomobile application,on submit of a POST method, i am going to my 'Model 1' action, after execution of my action i want to redirect to another model's (Model 2) Index action and list the data. 我正在开发Rhomobile应用程序,提交POST方法后,我要执行“模型1”操作,在执行我的操作后,我想重定向到另一个模型的(模型2)索引操作并列出数据。

I am from a Rails background, there i would have used URL, any similar concept exists here or any solution. 我来自Rails背景,在那里我会使用URL,这里存在任何类似的概念或任何解决方案。

i tried, but it didn't worked for me render :controller => :model2, :action => :index 我试过了,但是对我不起作用render:controller =>:model2,:action =>:index

Please Note: I have never used rhodes and all of this information was acquired by simply reading the API documentation and taking a look at the source code. 请注意:我从未使用过rhodes ,所有这些信息都是通过简单阅读API文档并查看源代码获得的。

According to the documentation You should be able to deal with this in a very railsy fashion eg 根据文档,您应该能够以非常讽刺的方式处理此问题,例如

   def some_action 
     redirect controller: :model2, action: :index
   end

Seems the only caveat is if this redirection is to happen in a callback function. 似乎唯一需要注意的是,此重定向是否要在回调函数中进行。 In this case the redirection should be handled by the WebView instead eg 在这种情况下,重定向应由WebView代替,例如

  Rho::WebView.navigate(url_for(controller: :model2 action: :index))  

Source for Rho::RhoController#redirect supports these statements in the documentation. Rho :: RhoController#redirect的源代码在文档中支持这些语句。

Additionally as you might notice above it appears that Rho has ported a lot of the rails like helpers including url_for 此外,正如您可能在上面注意到的那样, Rho似乎已经移植了很多导轨,例如包括url_for助手

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM