views:

310

answers:

3

Hi everyone I'm using the following code to map my resources for my products controller:


     map.namespace :admin do |admin|
       admin.resources :products
     end

In my view I'm using


link_to 'Edit', edit_admin_product_path(product)

which results in the URL /admin/products/1/edit

when I'm clicking on the link I'm getting

Unknown action No action responded to 1

so I guess it doesn't properly map it to the edit action I have no idea what to do

I would be very thankful for any help on this issue

A: 

What happen if you just go:

map.resources :products

... to map the resources?

Also what does this shows:

rake routes
marcgg
this doesn't work eitherI don't get this at all
MarcS
A: 

The is route valid otherwise it'd be blowing up when you try to create your link. Does your product controller have an edit action?

Usually when I put a namespace in my routes it follows through to my controller and views. For example the full path would be

/controllers/admin/products_controller.rb

/views/admin/products/edit.html.erb

You'd also put a namespace in your controller too:

class Admin::ProductsController < ApplicationController
Andy Gaskell
+1  A: 

Do you have these lines in your routes file?

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'

If so, make sure they are below your resource route lines. Those lines should always be near the bottom of your routes.rb because they are so generic. The more specific the route, the higher up it should be.

ryanb