Hmmm... basically you're talking about subclassing routes, or at least
aliasing them (so that myusertype_photo_url is the same as user_photo_url).
Looks like there's a ticket (http://dev.rubyonrails.org/ticket/10454) with
some ideas on how to fix it. In particular, you could override the
polymorphic_url method to check for a superclass before generating the
route.

On Thu, Apr 2, 2009 at 6:50 PM, moritz <[email protected]> wrote:

>
> The following stack trace
>
> NoMethodError (undefined method `my_user_type_photo_url' for
> #<UserNotifier:0x3cbd560>):
>    /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> polymorphic_routes.rb:112:in `__send__'
>    /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
> polymorphic_routes.rb:112:in `polymorphic_url'
>    /app/helpers/base_helper.rb:8:in `commentable_url'
>    /vendor/plugins/community_engine/app/models/user_notifier.rb:37:in
> `comment_notice'
>    /Library/Ruby/Gems/1.8/gems/actionmailer-2.2.2/lib/action_mailer/
> base.rb:462:in `__send__'
>    /Library/Ruby/Gems/1.8/gems/actionmailer-2.2.2/lib/action_mailer/
> base.rb:462:in `create!'
>    /Library/Ruby/Gems/1.8/gems/actionmailer-2.2.2/lib/action_mailer/
> base.rb:455:in `initialize'
>    /Library/Ruby/Gems/1.8/gems/actionmailer-2.2.2/lib/action_mailer/
> base.rb:392:in `new'
>    /Library/Ruby/Gems/1.8/gems/actionmailer-2.2.2/lib/action_mailer/
> base.rb:392:in `method_missing'
>    /vendor/plugins/community_engine/app/models/comment.rb:109:in
> `send_notifications'
>    /app/controllers/comments_controller.rb:156:in `create'
>
> made me think that I could implement a method
>
>  def my_user_type_photo_url(user, options)
>    user_photo_url(user, options)
>  end
>
> I tried it by adding it to base_helper.rb and it works for this case.
>
> Is there a better place to handle this?
>
> Is there a way to automate it, maybe?
>
> How can it be extended beyond photos?
>
> I'm still hoping for suggestions to improve the way this is handled.
>
> Thanks in advance for your suggestions.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to