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

76521 · 2013年06月13日 · 最后由 76521 回复于 2013年06月14日 · 2720 次阅读

如我有个方法
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'

这是楼主要找的么?

好的,谢谢啊

需要 登录 后方可回复, 如果你还没有账号请 注册新账号