Problem with error_messages_for


#1

Hi everyone,

I have this weird problem where error_messages_for isn’t working.

I have a model group which has to validates constraints…

class Group < ActiveRecord::Base
#directionality points to the user model
#this table contains the foreign key
belongs_to :user

validates_uniqueness_of :name
validates_presence_of :name

end


In the controller I have a method which persists this group

def create_group

if( group.save )
logger.debug( “group save successful”)
flash[:notice] = ‘Created group ’ + group.name + ’ successfully’
else
logger.debug( “group save unsuccessful”)
flash[:notice] = ‘Could not save group’
end

redirect_to :action=>“manage_friends”

end

in the manage_friends.rhtml i have the code…

<%= start_form_tag :controller=> “profile”, :action=> “create_group” %>

<%= error_messages_for ('group') %>

Create Group:

<%= text_field “group”, “name”, :size => 30 %>

<%= end_form_tag %>

<%= start_form_tag :controller=> “profile”, :action=>
“add_user_to_group” %>


but no text gets generated from the <%= error_messages_for call.

I also tried the error_messages with (:group)

Any ideas anyone!?!?!

Thanks,
-dan