新手问题 后台数据定向到前台页面问题

76521 · June 13, 2013 · Last by 76521 replied at June 14, 2013 · 2721 hits

如我有个方法
def contact_tags @tags = Tag.all.to_default_s

respond_with @tags do |format| format.html { render :index => 'index' } end

end 我不想把数据返回到默认的 contact_tags 页面,比如返回到 groups 中的 index 页面,form.html 那地方该怎么写啊?

2.2.3 Rendering an Action’s Template from Another Controller

What if you want to render a template from an entirely different controller from the one that contains the action code? You can also do that with render, which accepts the full path (relative to app/views) of the template to render. For example, if you’re running code in an AdminProductsController that lives in app/controllers/admin, you can render the results of an action to a template in app/views/products this way:

render 'products/show'

Rails knows that this view belongs to a different controller because of the embedded slash character in the string. If you want to be explicit, you can use the :template option (which was required on Rails 2.2 and earlier):

render :template => 'products/show'

这是楼主要找的么?

好的,谢谢啊

You need to Sign in before reply, if you don't have an account, please Sign up first.