开发者

How to render to another controller's action in Ruby on Rails 2.3.9

开发者 https://www.devze.com 2023-03-19 13:36 出处:网络
I\'m trying to render from a pnr controller to the index of a web_services and I need to specify a layout as well.

I'm trying to render from a pnr controller to the index of a web_services and I need to specify a layout as well.

I tried:

render :layout => "admin", :action => "web_services/index"
render :layout => "admin", :"web_services/index"
render :layout => "admin", :controller => "web_services", :action => "index"

and nothing works.

What should I use?

RESOLVED

DONE! I had to use:

redirect_to :layout => "admin", :controller => 'web_servic开发者_Python百科es', :action => 'index'


The :layout option for redirect_to is meaningless as redirect only needs a path and a status, and layout is just a name of the template. Also, as the name implies, redirect_to doesn't render anything, it tells the browser to go to another page. I suggest you to read the RoR guides at guides.rubyonrails.org.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号