One additional point. My workaround is to do this in the controller:

  @company = Company.get!(@team.company_id) # so the class is Company
and not Proxy

In the view, I then use @company and not @team.company. It is an ugly
situation.

I could use named URLs with the #url method and avoid this problem
entirely, but I want to be consistent and use #resource for all CRUD
links. Perhaps I will change my mind if the problem with the class
name proves to be intractable :-)

..tony..

On Dec 3, 4:21 pm, phatmann <[EMAIL PROTECTED]> wrote:
> I discovered an interesting issue with Controller#resource today:
>
>   resource(Company.first, :teams)
>
> works fine but
>
>   resource(@team.company, :teams)
>
> fails to find the route!
>
> After some digging, I discovered the problem. To find the route,
> #resource uses the object's class name as part of the route key.
> Company.first is of class Company, and @team.company is of class
> DataMapper::Associations::ManyToOne::Proxy. The interesting thing is
> that calling inspect on each of them gives the same results, since
> Proxy overrides #kind_of?, so this problem took me a while to find.
>
> I suppose DataMapper::Associations::ManyToOne::Proxy should forward
> #class as well, unless there is another solution anyone could propose.
> Is there a different method that resource could be using to turn the
> class into a key?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" 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/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to