route_key

route_key(record_or_class)
Class Public methods

Returns string to use while generating route names. It differs for namespaced models regarding whether it's inside isolated engine.

# For isolated engine:
ActiveModel::Naming.route_key(Blog::Post) # => "posts"

# For shared engine:
ActiveModel::Naming.route_key(Blog::Post) # => "blog_posts"

The route key also considers if the noun is uncountable and, in such cases, automatically appends _index.

doc_ruby_on_rails
2015-06-20 00:00:00
Comments
Leave a Comment

Please login to continue.