Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some documantation on new route_key and param_key in ActiveModel:…

…:Naming
  • Loading branch information...
commit bf1ac82cecfb3291a9bc215974b385a1b3ccb545 1 parent 6f3119d
@drogus drogus authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 activemodel/lib/active_model/naming.rb
View
16 activemodel/lib/active_model/naming.rb
@@ -95,10 +95,26 @@ def self.uncountable?(record_or_class)
plural(record_or_class) == singular(record_or_class)
end
+ # 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
def self.route_key(record_or_class)
model_name_from_record_or_class(record_or_class).route_key
end
+ # Returns string to use for params names. It differs for
+ # namespaced models regarding whether it's inside isolated engine.
+ #
+ # For isolated engine:
+ # ActiveModel::Naming.route_key(Blog::Post) #=> post
+ #
+ # For shared engine:
+ # ActiveModel::Naming.route_key(Blog::Post) #=> blog_post
def self.param_key(record_or_class)
model_name_from_record_or_class(record_or_class).param_key
end
Please sign in to comment.
Something went wrong with that request. Please try again.