Just learning Rails… So this is probably a noob question. My
apologies.
Could anyone please give me a quick summary/example on the usage of
error_messages_for?
I have two tables/models, Group and GroupMembers. Obviously, a Group
has_many GroupMembers. I have a customized view which shows a list of
GroupMembers followed by a field and a button which facilitates adding a
member to the group by either email address or login.
When the user attempts to add someone to the group who is already there,
I
need to return to this EditMembers view with an error message.
I cannot figure out how to use error_messages_for to display the error
message when returning to the view. The most natural thing to attach
the
messages to seems to be the GroupMember object, but the new groupmember
object doesn’t exist until the button action and not on the first view
of
the groupmembers list, so I get a reference to a nil object.
If anyone could provide me with some pseudocode of how it should work,
that
would be great! Thanks!