Thanks to the folks who suggested solutions to this question. I was
trying to look deeper under the covers than I needed to and didn't see
the obvious in front of my face. At first, I was suspicious of trusting
a derived string for my answer, but then I looked into
ActionController::Base and saw the code there doing a similar thing.
Since methods like controller_class_name, controller_name and
controller_path all depend ultimately on the class name itself, I'll go
with controller.class.name and split out the modules as needed. As it turns out, I've backed away from the refactoring I had intended to do, so I don't need that particular code right now (no doubt it will be useful in the future). Part of the reason of the refactoring was to make my code more RESTful. This is probably the 3rd or 4th time I have decided to do this, but each time I come to the same conclusion: it's not worth it. My problem, I realise, is with generalising named routes. For me, it seems writing, for example: redirect_to :action ="" :list which is able to infer the controller, is easier than redirect_to(some_model_url) which needs the controller context to be explicitly built into the route name. When it comes to generalising some controller code that can handle any model, the named route solution is slightly messier. I'm wondering if I get branded an apostate for not being sold on RESTfulness but since I already have a standard set of actions in an abstract controller class (which my 'concrete' controllers simply inherit from), it seems that going the whole RESTful route adds little value. Any thoughts? thanks in advance Mark P.S. the fruits of this current work I've assigned myself will soon be appearing on a github near you in the form of some plugins and 2.3 Engines. More later :-) David Lee wrote: do you want to operate on the class/module constant or the url path? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to rails-oceania@googlegroups.com To unsubscribe from this group, send email to rails-oceania+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~--- |
- [rails-oceania] Reminder: rorosyd meetup tonight! Jason Crane
- [rails-oceania] Trying to discover the module of a con... Mark Ratjens
- [rails-oceania] Re: Trying to discover the module ... Clifford Heath
- [rails-oceania] Re: Trying to discover the mod... John Barton
- [rails-oceania] Re: Trying to discover the... David Lee
- [rails-oceania] Re: Trying to discove... Mark Ratjens