Jochen
things look a bit nicer and consistent with other functions. I am sure
there must be a function for this somewhere in Rails, because it
has to
do it itself for each request, but I can’t find it.
Jochen, you can take a look at the Inflector - methods as
Inflector::modulize, symbolize, demodulize, constantize etc.
However, it “feels” to me that you are trying to do something which
already IS in rails, you just not know how to get to it.
For instance, have you thought about asking Routes if your route is
mappable and hiding the link if it’s not there? I think if you could
do that
you would get away with much less code that what you are trying to do
now.
On Sat, Nov 19, 2005 at 04:27:39PM +0100, Stefan K. wrote:
If you’re inside the controller you can call
action_methods.include?(‘bar’). From the outside, it’s
FooController.action_methods.include?(‘bar’).
Thanks. That solves half of the problem. But is there also a way to get
from the string ‘foo’ to the controller ‘FooController’? This would make
things look a bit nicer and consistent with other functions. I am sure
there must be a function for this somewhere in Rails, because it has to
do it itself for each request, but I can’t find it.
On Sat, Nov 19, 2005 at 07:35:10PM +0100, Julian ‘Julik’ Tarkhanov
wrote:
controller, but only when this action is actually supported.
from the string ‘foo’ to the controller ‘FooController’? This would
For instance, have you thought about asking Routes if your route is
mappable and hiding the link if it’s not there? I think if you could
do that
you would get away with much less code that what you are trying to do
now.
Well, how would I ask Routes if my route is mappable? I couldn’t find
any documentation about this.
like
controller, but only when this action is actually supported.
Thanks. That solves half of the problem. But is there also a way to get
from the string ‘foo’ to the controller ‘FooController’? This would make
things look a bit nicer and consistent with other functions. I am sure
there must be a function for this somewhere in Rails, because it has to
do it itself for each request, but I can’t find it.
Jochen
Fo top level controllers you can do
Module.const_get('foo'.camelize + "Controller")
If your controller lives inside a module, with a patch like “admin/foo”,
it’s probably