I am using Ruby on Rails 3.0.7 and I would like to retrieve a controller name given a class name. That is, I have
Articles::Category
and I would like to retrieve
articles/categories
I would like to retrieve the controller name inside a view file not related to the Articles::Categories
controller.
How can I do that (possibly using some Ruby on Rails core method)?
Articles::Category.name.underscore.pluralize
=> "articles/categories"
As mentioned by many others, there is no special method for that. But as long as you followed Rails conventions, this approach will take you far.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With