aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/record_identifier.rb
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2012-06-28 23:54:12 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2012-06-30 11:04:31 -0500
commit166dbaa7526a96fdf046f093f25b0a134b277a68 (patch)
tree665afc57ce1ddde3439c1f0296f1ca51e0b2fe05 /actionpack/lib/action_controller/record_identifier.rb
parent809bdf342638592b0dfd2f888c7c9a4ac093d8cf (diff)
downloadrails-166dbaa7526a96fdf046f093f25b0a134b277a68.tar.gz
rails-166dbaa7526a96fdf046f093f25b0a134b277a68.tar.bz2
rails-166dbaa7526a96fdf046f093f25b0a134b277a68.zip
Remove ActiveModel dependency from ActionPack
ActiveModel is used in ActionPack for ActiveModel::Naming for a few, mostly optional aspects of ActionPack related to automatically converting an ActiveModel compliant object into a key for params and routing. It uses only three methods of ActiveModel (ActiveModel::Naming.route_key, ActiveModel::Naming.singular_route_key and ActiveModel::Naming.param_key).
Diffstat (limited to 'actionpack/lib/action_controller/record_identifier.rb')
-rw-r--r--actionpack/lib/action_controller/record_identifier.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb
index 16a5decc62..d3ac406618 100644
--- a/actionpack/lib/action_controller/record_identifier.rb
+++ b/actionpack/lib/action_controller/record_identifier.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/module'
+require 'action_controller/model_naming'
module ActionController
# The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
@@ -27,6 +28,8 @@ module ActionController
module RecordIdentifier
extend self
+ include ModelNaming
+
JOIN = '_'.freeze
NEW = 'new'.freeze
@@ -40,7 +43,7 @@ module ActionController
# dom_class(post, :edit) # => "edit_post"
# dom_class(Person, :edit) # => "edit_person"
def dom_class(record_or_class, prefix = nil)
- singular = ActiveModel::Naming.param_key(record_or_class)
+ singular = model_name_from_record_or_class(record_or_class).param_key
prefix ? "#{prefix}#{JOIN}#{singular}" : singular
end
@@ -73,8 +76,7 @@ module ActionController
# method that replaces all characters that are invalid inside DOM ids, with valid ones. You need to
# make sure yourself that your dom ids are valid, in case you overwrite this method.
def record_key_for_dom_id(record)
- record = record.to_model if record.respond_to?(:to_model)
- key = record.to_key
+ key = convert_to_model(record).to_key
key ? key.join('_') : key
end
end