Fraser
Fraser

Reputation: 1521

link_to with Namespaces in Rails

I'm trying to get an admin interface working in Rails, but I'm having trouble using link_to with the nested routes. I'm trying to get a link to /admin/cake_class/:id but it's sending me to admin/cake_class.:id instead.

config/routes.rb:

namespace :admin do
    resources :cake_class
end

/app/views/admin/cake_class/index.html.erb

<h1>all classes</h1>

<% @classes.each do |c| %>

    <%= c.date %>
    <%= c.name %>
    <%= link_to 'Show', admin_cake_class_path(c) %>

<% end %>

Any suggestions?

Upvotes: 0

Views: 465

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

The :resources should be plural, :cake_classes, which could be tripping you up.

What does the output of rake routes show?

Upvotes: 1

Related Questions