undefined method `singular_route_key'' for "User":ActiveModel::Name

John Merlino
Mon, 03 Sep 2012 23:36:30 -0000

In ActionDispatch::PolymorphicRoutes, there is a call to
build_named_route_call an on line 172 (of latest rails code from
github), there is a call to singular_route_key:

model_name_from_record_or_class(parent).singular_route_key

Now  model_name_from_record_or_class returns an ActiveModel::Name
object, which is a wrapper to the string class, that returns a string
name of the class of an activerecord model. I launch the console and
try to invoke singular_route_key, and it gives me undefined method:


1.9.2p290 :004 > @user.class.model_name.class
 => ActiveModel::Name
1.9.2p290 :005 > @user.class.model_name.singular_route_key
NoMethodError: undefined method `singular_route_key'' for
"User":ActiveModel::Name

So what''s different here? How come it works in the live rails code but
not in the rails console? I asked a similar question on stackoverflow
and did not get a response, so I would really appreciate a response
here.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.