aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-09-01 11:02:28 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:15 +0200
commitbf1ac82cecfb3291a9bc215974b385a1b3ccb545 (patch)
tree4156de9546f761dfd85911e1a2f571167ed577b1 /activemodel
parent6f3119d3c298c007e7a4eed8375d9fc30b961d06 (diff)
downloadrails-bf1ac82cecfb3291a9bc215974b385a1b3ccb545.tar.gz
rails-bf1ac82cecfb3291a9bc215974b385a1b3ccb545.tar.bz2
rails-bf1ac82cecfb3291a9bc215974b385a1b3ccb545.zip
Add some documantation on new route_key and param_key in ActiveModel::Naming
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/naming.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 1eb1abdb52..dadb1882e4 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -95,10 +95,26 @@ module ActiveModel
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