How does form validation works on restful controllers

Hi all,

Let's assume I have a calendar show view (calendar controller). On
that view you can view a calendar with all its events. You can also
add, edit and delete events (via the events controller) on that same

Let's assume the user creates a new event but forgets to fill in some
data and the validation (and insert operation) fails. You want to use
the render :action => 'calendars/show' method to show the validation
error on the form in the calendar controller.

The problem I'm facing is that when you render the calendar view you
need other variables (like all the events of the calendar). Of course
you can add @events = Event.find(:all) in the create method of the
events controller but in my opinion this completely ruins the restful
philosophy: your create method isn't a real create method anymore, it
has also become an index method.

I'm really interested in your opinion and how you design your
controllers to solve this problem.

Many thanks in advance.

This is one of those fundamental design issues that some people might
argue I get wrong.

I would put the event handling, editing, and all that in the calendar

Why? Because events don't really live outside that context. They are
modified through the calendar the user sees, and they are displayed on
it. Sure, there are event lists that you might have outside it, but
isn't a list of events just a schedule, which is another form of

In my code, I have "users", "toons", and "avatars" -- the Avatar is a
small picture that is specific to a Toon. I put all the avatar logic
in toon_controller.rb, since modifying a toon is done along the same
lines as modifying the Toon attributes of level, class, etc. From a
user's point of view, and from mine, an Avatar is just another
attribute on a Toon.

When I think of a calendar, I think of events on it. I don't think of
an event standing alone, I think of it as something that occurs on a
specific day and time, which is a calendar.