I was already in there, trying various permutations for just such a
Game special case. This generates 'member_game_url':

  def commentable_url(comment)
    if comment.recipient && comment.commentable
      if comment.commentable_type == "Game"
        debugger
        polymorphic_url([comment.commentable.member,
                                 comment.commentable])+"#comment_#{comment.id}"
      elsif ...

member_game_url has no route because Member is just a model, and has
no controller. Put another way, Members don't own Photos, Users do.
The desired route is user_game_url, which has me thinking that maybe
LostyJai's suggestion would be appropriate, as this isn't the result
of a bug in polymorphic_url.

Thoughts?


On Fri, May 29, 2009 at 6:33 PM, Bruno Bornsztein
<[email protected]> wrote:
> Look at commentable_url in BaseHelper. It calls:
>         polymorphic_url([comment.recipient,
> comment.commentable])+"#comment_#{comment.id}"
> So it uses the recipient of the comment (which is a user) for comments on
> anything other than users. You can overwrite that method to make an
> exception for Games, something like (pseudo-code):
> if comment.commentable_type == "Game"
>   polymorphic_url([comment.commentable.member, comment])
> #comment.commentable should return a Game
> end
> Good luck,
> Bruno
> On Fri, May 29, 2009 at 8:06 PM, LostyJai <[email protected]> wrote:
>>
>> Have you defined your model as a subclass of user in routes?
>>
>> On May 30, 8:52 am, angrysponge <[email protected]> wrote:
>> > I have a Game model which I would like to enable comments for. Games
>> > are owned by Members, which is a subclass of User. The relevant model
>> > code needed thus far:
>> >
>> > class Game < ActiveRecord::Base
>> >   belongs_to :member
>> >   acts_as_commentable
>> >   def owner
>> >     self.member.becomes(User)
>> >   end
>> >
>> > class Member < User
>> >   has_many :games
>> >
>> > Saving a comment for a Game generates this error:
>> > NoMethodError in CommentsController#create
>> > undefined method `user_game_url' for #<CommentsController:0xb6daef9c>
>> >
>> > When adding a comment to a Photo, polymorphic_url() returns
>> > 'user_photo_url', so 'user_game_url' looks reasonable, except that
>> > Users don't own Games, Members do.
>> >
>> > Am I missing some route details for my Game model?
>> >
>> > Any suggestions?
>> > Mike
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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