Need help named route and link_to

Hi,

In my application I’ve set up a custom route that works as long as I
stay within the same model. This makes me think that I must have
something wrong with the route.

map.agent ‘:agent’, :controller => ‘agents’, :action => ‘show’
The resulting url is http://www.domain.com/firstname-lastname

The problem that I have is creating a link_to from a view outside of
agents. I currently have this, but this will

<%= link_to_unless(@property.agent.nil?, “view bio”,
@property.agent.permalink) %> generates this:
http://www.domain.com/properties/firstname-lastname

Any ideas how to get this all to work correctly?

Thanks!

Hi,

On Fri, Oct 30, 2009 at 4:31 PM, Cs Webgrl
<[email protected]

wrote:

The problem that I have is creating a link_to from a view outside of
agents. I currently have this, but this will

<%= link_to_unless(@property.agent.nil?, “view bio”,
@property.agent.permalink) %> generates this:
http://www.domain.com/properties/firstname-lastname

Can’t you do this? <%= link_to_unless(@property.agent.nil?, “view bio”,
{agent_url, :name => @property.agent}) %> or whatever your name would
default to

Any ideas how to get this all to work correctly?

Thanks!

Posted via http://www.ruby-forum.com/.


www.abetaday.com

Gregory M. wrote:

Can’t you do this? <%= link_to_unless(@property.agent.nil?, “view bio”,
{agent_url, :name => @property.agent}) %>

Unfortunately that generates an error:

compile error
/show.rhtml:138: syntax error, unexpected tASSOC, expecting ‘}’
… :agent => @property.agent.permalink}) )…

Gregory M. wrote:

{:controller
=> ‘agents’, :action => ‘show’, :agent => @property.agent.permalink} and
see
if that works.

Excellent! That worked. I had tried a variation of that, but must of
missed something.

Thanks for your help!

On Fri, Oct 30, 2009 at 5:52 PM, Cs Webgrl
<[email protected]

wrote:

compile error
/show.rhtml:138: syntax error, unexpected tASSOC, expecting ‘}’
… :agent => @property.agent.permalink}) )…

Sorry, it’s tough for me to guess with just this. As a check, you can
replace {agent_url, :agent => @property.agent.permalink} with
{:controller
=> ‘agents’, :action => ‘show’, :agent => @property.agent.permalink} and
see
if that works.


www.abetaday.com