如何在另一个页面上显示错误?如何在另一个页面上显示错误信息?
我的用户文件夹
下,并在另一个地方,my_account的文件夹形式,我呈现来自my_account的索引页面中的用户文件夹的形式。这样我可以重用表单,以允许用户更新他们的用户信息。
因此,当用户点击更新,在UserController的更新方法将被调用。
我的问题是,如果zhcon失败更新用户对象,我怎么能显示到my_account的索引页错误消息,并且仍然有场重头戏,和错误信息? 如无效的电子邮件地址的格式
User
-- new.html.erb
-- _form
my_account
-- index.html.erb
我试着做以下,但不知道如何可以打印my_account的页面中的“错误”:
// try to update user information
// if failed, redirect to my account page
format.html { redirect_to my_account_path, :error => @user.errors }
您好ghayes,我得到错误丢失模板../my_account/index {:handlers => [:erb,:rjs, :builder,:rhtml,:rxml],:formats => [:html],:locale => [:en,:en]}。我需要在路由配置中执行任何操作吗? – jojo
将路径更改为“/ my_account/index”...并且它正在为我工作....很棒thx .. – jojo