Martin, This is pretty cool stuff. I like the auto-populated instance variables. And the goal of a one-line controller is laudable. As you mention, it needs better integration with the router. Then you would normally not need a controlling call at all, since naming conventions would suffice.
The only part I do not like is all the methods for overriding different aspects of each action, as the overall result might be wordier and less understandable than hand-rolled actions, if one customizes sufficiently. However, I don't have a better idea right now. It's a tough problem. But I definitely agree that the currently generated controllers are all very similar, and it would be great to capture this in a mix-in or superclass. This might have to be baked into Merb at a pretty deep level to be effective and clean. And I wonder how this plays with the soon-to-be Resource class? For my needs, I would like something a little lighter weight. I already extend Application in my app to provide an #owner method that gets the resources parent. I might keep going to add automatic methods for fetching resources via the params. For example, #foo to get the Foo instance. Etc. ..tony.. On Wed, Dec 17, 2008 at 2:29 PM, Martin Gamsjaeger <[email protected]>wrote: > > Hey Tony (and really everyone else :-) > > Sorry, my answer isn't really related to the original question, but if > you're interested in DRYing up your controllers you might want to look > at > > http://github.com/snusnu/merb_resource_controller/tree/master > > I just pushed a few fixes and features. The main new feature being > support for all kinds of content types. XML, JSON, YML and CSV work > out of the box. For others, configuration is really simple. > > It also supports arbitrarily nested resources (although 2 level > nestings *should* be enough most of the times) and singleton > resources. It also uses the same controller class for different parent > nestings and gives you helpers for parent_resource URLs although these > could definitely be approved! > > Let me know what you think > > cheers > snusnu > > On Wed, Dec 17, 2008 at 22:41, Michael Klishin > <[email protected]> wrote: > > > > > > On 18.12.2008, at 0:34, Tony Mann wrote: > > > >> On a related note, it would be great to have a #resource method in > >> Controller that would grab :id from params and instantiate the > >> class. No more foo = Foo.get(id) all over the controller code! > > > > > > Here you go: http://gist.github.com/37243 > > > > MK > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
