aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/polymorphic_routes.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_dispatch/routing/polymorphic_routes.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_dispatch/routing/polymorphic_routes.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 86ce7a83b9..3d7b8878b8 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -1,3 +1,5 @@
+require 'action_controller/model_naming'
+
module ActionDispatch
module Routing
# Polymorphic URL helpers are methods for smart resolution to a named route call when
@@ -53,6 +55,8 @@ module ActionDispatch
# form_for([blog, @post]) # => "/blog/posts/1"
#
module PolymorphicRoutes
+ include ActionController::ModelNaming
+
# Constructs a call to a named RESTful route for the given record and returns the
# resulting URL string. For example:
#
@@ -154,10 +158,6 @@ module ActionDispatch
options[:action] ? "#{options[:action]}_" : ''
end
- def convert_to_model(object)
- object.respond_to?(:to_model) ? object.to_model : object
- end
-
def routing_type(options)
options[:routing_type] || :url
end
@@ -169,7 +169,7 @@ module ActionDispatch
if parent.is_a?(Symbol) || parent.is_a?(String)
parent
else
- ActiveModel::Naming.singular_route_key(parent)
+ model_name_from_record_or_class(parent).singular_route_key
end
end
else
@@ -181,9 +181,9 @@ module ActionDispatch
route << record
elsif record
if inflection == :singular
- route << ActiveModel::Naming.singular_route_key(record)
+ route << model_name_from_record_or_class(record).singular_route_key
else
- route << ActiveModel::Naming.route_key(record)
+ route << model_name_from_record_or_class(record).route_key
end
else
raise ArgumentError, "Nil location provided. Can't build URI."