account_settings
我在控制器中有一个表单,它user
通过users_controller
. 错误消息没有通过。下面看一下代码。
account_settings/account.html.haml
= form_for @user, :url => { :controller => "users", :action => "update", :id => @user.id } do |f|
- if @user.errors.any?
.alert.alert-error
%h4
Please address the following errors:
%ul
- @user.errors.full_messages.each do |msg|
%li= msg
form stuff...
account_settings_controller
def account
@user = current_user
end
users_controller
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = "User was successfully updated."
end
redirect_to :back
end
表单不会更新,但不会传回错误消息。有什么想法吗?