For reference: http://groups.google.com/group/datamapper/browse_thread/thread/5e4136062c7ab380 (yes, I realize this is phatmann's post)
Seems like the problem was fixed on edge. On Dec 3, 6:05 pm, phatmann <[EMAIL PROTECTED]> wrote: > I posted to the DM group, thanks for the suggestion. > > My colleague suggested an interesting workaround that Merb could > implement: > > class Object > def real_class_name > class.to_s > end > end > > class Proxy > def real_class_name > parent.class.to_s > end > end > > And then #resource would use real_class_name instead of class_name. > > ..tony.. > > On Dec 3, 5:32 pm, "Martin Gamsjaeger" <[EMAIL PROTECTED]> wrote: > > > Heh, I would be interested in this as well! Maybe you should post this > > question to the datamapper group as well? > > > I think that generally relying on #class is the safest bet for > > #resource to do it's job. Since (some of) the Proxy's job is to > > pretend to be something else anyway, and it already overrides > > #kind_of? maybe it's possible to override #class as well. But maybe > > there's a reason that they haven't done so yet. > > > I really think this should be posted > > tohttp://groups.google.com/group/datamapperaswell! > > > cheers > > snusnu > > > On Thu, Dec 4, 2008 at 1:28 AM, phatmann <[EMAIL PROTECTED]> wrote: > > > > One additional point. My workaround is to do this in the controller: > > > > [EMAIL PROTECTED] = 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 -~----------~----~----~----~------~----~------~--~---
