Forum: Ruby on Rails problem with error_messages_for

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8e6ba70855b8f3a84e7c54fb732e4bbd?d=identicon&s=25 palidanx (Guest)
on 2006-06-07 09:29
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...
------------
<!-- CREATE GROUP -->
<%= start_form_tag :controller=> "profile", :action=> "create_group" %>

<div title="create group" id="creategroupform" class="form">
  <%= error_messages_for ('group') %><br/>

<b>Create Group:  </b><br>
  <%= text_field "group", "name", :size => 30 %><br/>

<input type="submit" value="Create Group &#187;" class="primary" />
</div>
<%= end_form_tag %>

<!-- ADD FRIEND TO USER GROUP -->
<%= 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
This topic is locked and can not be replied to.