I am having trouble getting error_messages_for to work.
My controller(relevant parts) looks like
def configure
@account = session[:account]
@user = User.new
end
def add_new_user_to_account
@user = User.new(params[:user])
if @user.valid?
session[:account].users << @user
end
redirect_to :action=> ‘configure’
end
end
and my view configure.rhtml
<%= error_messages_for ‘user’ %>
<%=start_form_tag :action =>‘add_new_user_to_account’%>
First Name: <%=text_field ‘user’, ‘first_name’%>
Last Name: <%=text_field ‘user’, ‘last_name’%>
Username: <%=text_field ‘user’, ‘username’%>
Password: <%=password_field ‘user’, ‘password’%>
Email: <%=text_field ‘user’, ‘email’%>
Admin?<%=check_box(“user”, “admin”)%>
<%=submit_tag%>
<%=end_form_tag%>
If I enter data that does not validate the record is not saved (which is
good) but error_messages_for ‘user’ doesn’t show any errors(which is
bad). If I go into the console and make an invalid user I am shown the
correct errors in @user.error so my validations are working on the
model, they just aren’t making their way through the controller to the
view.
Any ideas?
Thank you,
Matthew M.
blog.mattmargolis.net