开发者

Rails redirect without changing URL

I've some piece of ruby/rails code.

In one of the controllers say foo i have an action doo which does something and I want to redirect to another controller say bar and action say dar.

When I use redirect_to then URL in the address bar changes to /bar/dar while if I use render then I don't know how to render another controller's view.

I am using rails 2.3.5 so render_component is unavailable for use (which i found could be really really useful for me) -- so as a shortcut if you have any开发者_如何学JAVA idea of alternate for render_component that will help me infinitely.

Any ideas?

[If am unclear please ask me details]


Instead of a real redirect, could you use an AJAX call to hit the action and pull in the appropriate views?


You can render the same partial from both views. You'll have a view for each action and in each of the views you'll have something like <%= render :partial => "partials/form" %>.


You can just call the action (like calling a function) and then render the template. But accordingly to the MVC pattern you should manage your controller-side logic on the controller and then loads the propper view.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜