Namespaces, dynamic links and routing

12 views
Skip to first unread message

Jason O

unread,
Nov 6, 2015, 8:14:01 AM11/6/15
to Ruby on Rails: Talk
Hello all!

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

First - 

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>
<p><%= person.title %></p>
<p><%= person.position.capitalize %></p>
</div>


Secondly, the current route resolves to address.com/people/{:id} and I would like to it resolve to address.com/{:user_name} and I am not sure how to get this to work. I have tried a few different options but I am not quite sure what I am doing here. 

resources :people, only: [:index, :show] do
   resources :pubs, except: [:create, :new, :edit, :destroy]
end


I have attempted to add  —>    get 'people/:id/user_name' => 'people#user_name', as: :user_name
but this has not worked. 

Thanks for any help!

Jason
Reply all
Reply to author
Forward
0 new messages