Return the file name of the current controller?

Okay, so I’m working on a project and I’m using the
shared-controller/views method described here
(http://dereksivers.com/rails-shared-controller.html). I’m taking a
RESTful approach with this project, so I’d like to use the named routes
that are generated for each resource (i.e. ‘news_path’, ‘events_path’,
etc.). Problem is, my shared views need to know the name of the
controller that I’m working in so I can generate these named routes in
my link_to and form tags.

I know that in the template that the scaffold generator creates it
accesses the current action’s name using controller.action_name…is it
possible to do the same for a controller? controller.class returns the
classified name (i.e. ‘NewsController’), but I need the “file name”
(i.e. ‘news’). I’ve tried a ton of possibilities, and I can’t find
anything in the documentation that might help me.

Any help is appreciated!

Andrew

controller.controller_name

Eden Li wrote:

controller.controller_name

Ah…I’m an idiot, haha. Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs