"Generation Error - Resource route not found" calling resource() for associated record

3 views
Skip to first unread message

glenc

unread,
Dec 21, 2008, 8:55:17 PM12/21/08
to merb
I'm not sure if this is a DataMapper issue or a Merb issue. I have
two models - Project and Company. Project has a belongs_to :company
association. Company has a "has n :projects" association.

On the show view for a project, I want the associated company along
with a link to that company's show action.

Calling resource() with the associated object directly results in a
Generation Error. However, if I load the company recored fresh from
the database, it works.

Doesn't Work:
<%= link_to @project.company.name, resource(@project.company) %>

Works:
<%= link_to @project.company.name, resource(Company.get
(@project.company.id)) %>

Do I need to do something different with my associations? Is this a
bug or am I just missing something?

Thanks,
Glen

Tony Mann

unread,
Dec 21, 2008, 10:05:34 PM12/21/08
to me...@googlegroups.com
This has been discussed before in the DM list. The associated object is actually a Proxy. The workaround for now is to get the object from the db directly just as you are doing. This was supposed to be fixed in the latest DM release (by having Proxy override the class method), but I have not checked to see if the patch made it in.

..tony..
Reply all
Reply to author
Forward
0 new messages