【发布时间】:2012-02-15 16:48:40
【问题描述】:
我对正在学习的教程有疑问。有一个注册部分的代码,当验证没有通过时,Rails 会再次呈现动作。一切正常,但显然 URL 看起来不一样:
http://localhost:3000/signup - 在点击按钮之前
http://localhost:3000/Users - 使用无效详细信息点击按钮后
这是代码:
@user = User.new(params[:user])
if @user.save
flash[:success] = "Welcome to the Sample Application!"
redirect_to @user
else
render 'new'
end
有没有办法通过redirect_to 传递@user 对象,以便它显示正确的URL并且用@user 输入的详细信息填充表单(使用form_for)?
【问题讨论】:
标签: ruby-on-rails