hi all,
I try to get error_message_for to get to work on my dorm. No luck…
For some reason the view doesn’t show me the error message when I for
example leave out the first_name
Some has a clue what I’m doing wrong?
Thanks,
Stijn
I use a helperform to create a new user:
New user
<%= error_messages_for 'user' %> <%= form_tag new_user_path %> first_name: <%= text_field('user', 'first_name') %>last_name: <%= text_field('user', 'last_name') %>
email: <%= text_field('user', 'email') %>
<%= end_form_tag %>
the controller
def new
@user = User.new(params[:user])
if @user.save
flash[:notice] = “Nieuwe gebruiker aangemaakt”
end
redirect_to :back
end
the model
class User < ActiveRecord::Base
has_and_belongs_to_many :nodes
has_many :posts
validates_presence_of :first_name, :last_name
end