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: <h2>New user</h2> </form> <%= error_messages_for 'user' %> <%= form_tag new_user_path %> <label for="user_first_name">first_name: </label><%= text_field('user', 'first_name') %><br/> <label for="user_last_name">last_name: </label><%= text_field('user', 'last_name') %><br/> <label for="user_email">email: </label><%= text_field('user', 'email') %><br/> <input type="submit" value="new"> <%= 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