Ryan
Ryan

Reputation: 6652

Alias Route to Controller

I have a model called PointOfContact I created with a scaffold; so it should have some semblance of correctness about it.

Basically, I want an alias for my routes. Instead of going to '/point_of_contacts', I want '/pocs' and I don't want '/point_of_contacts' to be a valid route.

I have tried this:

resources :pocs, :controller => "point_of_contacts"

That works to create the '/pocs' route. However, now I am unsure as to how my Views should be written. Specifically:

<% @point_of_contacts.each do |point_of_contact| %>
  <tr>
    <td><%= point_of_contact.first %></td>
    <td><%= point_of_contact.last %></td>
    <td><%= point_of_contact.title %></td>
    <td><%= point_of_contact.phone %></td>
    <td><%= point_of_contact.email %></td>
    <td><%= link_to 'Show', point_of_contact %></td>
  </tr>
<% end %>

That code creates this exception:

No route matches {:action=>"show", :controller=>"point_of_contacts", :id=>#<PointOfContact id: 1, system_id: nil, first: "Tester", last: "Test", title: "", phone: "", email: "", created_at: "2011-03-10 20:03:21", updated_at: "2011-03-10 20:03:21">}

Upvotes: 0

Views: 3054

Answers (1)

Augusto
Augusto

Reputation: 29947

Try resources :point_of_contact, :path => "/pocs"

Upvotes: 9

Related Questions