【发布时间】:2010-12-17 22:40:02
【问题描述】:
好的,所以我有一个 User,它有一个 Template,我想要一个基本上只是 Template 的编辑视图的页面。
我有:
class TemplatesController < ApplicationController
def edit
@template = current_user.template
end
def update
@template = current_user.template
if @template.update_attributes(params[:template])
flash[:notice] = "Template was successfully updated"
end
render :edit
end
结束
现在的“问题”是当我调用 render :edit 时,我实际上最终使用的是 /template.1 而不是 /template/edit,这正是我所期望的。显然,如果我调用 redirect_to :edit 那么我会得到我期望的路径,但如果有任何对象错误,我会丢失。
有没有更好的方法来做到这一点?
谢谢!!
【问题讨论】:
标签: ruby-on-rails controller render ruby-on-rails-3