Dynamic Links within a namespace

29 views
Skip to first unread message

Ja Orman

unread,
Nov 9, 2015, 9:27:52 AM11/9/15
to rubyonra...@googlegroups.com
Hello all!

I am new to all of this and I am trying to accomplish something, and I
am hoping that someone will be able to assist me…


I am trying to set up a namespace within a dynamic link. I have created
an admin namespace and I need to following link to go to
../admin/people/xxx

<div class="inner">
<p><%= link_to(person) do %>
<strong><%= person.fname %> <%= person.lname %></strong>
<% end %></p>
</div>

Am I missing something from the controller or what? How do I get this
dynamic link to go to the namespace route and not the base page? Does
something go in the <%= link_to(person) do %> and if so what? I am just
so new to all of this, I am not sure how to solve this problem.


Thanks for any help!

Jason

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

dasibre

unread,
Nov 9, 2015, 12:48:34 PM11/9/15
to Ruby on Rails: Talk
Why not just use named routes. if you've namespaced your admin routes, you should have various routes available to you

Matt Jones

unread,
Nov 9, 2015, 3:24:24 PM11/9/15
to Ruby on Rails: Talk
This isn't mentioned in the `link_to` documentation, but looking at the source it appears you can pass the same sort of thing you'd give `polymorphic_path` to get namespace routes.


So something like `link_to([:admin, person]) do` in your example should do the trick.

--Matt Jones

Hoang Tran

unread,
Nov 11, 2015, 4:57:45 AM11/11/15
to rubyonra...@googlegroups.com
you fail at
<%= link_to(person) do %>

You can follow me same as:
<div class="inner">
<p><%= link_to admin_person_path(person) do %>
<strong><%= person.fname %> <%= person.lname %></strong>
<% end %></p>
</div>

Jason Or

unread,
Nov 12, 2015, 10:32:08 AM11/12/15
to rubyonra...@googlegroups.com
This worked perfectly! Thank you!!!
Reply all
Reply to author
Forward
0 new messages