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! -- Posted via http://www.ruby-forum.com/.
Hi, On Fri, Oct 30, 2009 at 4:31 PM, Cs Webgrl <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gregory Mazurek 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}) )... -- Posted via http://www.ruby-forum.com/.
On Fri, Oct 30, 2009 at 5:52 PM, Cs Webgrl <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Gregory Mazurek 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}) )...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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gregory Mazurek 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! -- Posted via http://www.ruby-forum.com/.