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 view. 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. Stijn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Graff
2007-Oct-18 17:18 UTC
Re: How does form validation works on restful controllers
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 controller. 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 calendar? 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. --Michael --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---