简体   繁体   中英

How do I set up a route in rails?

In my routes.rb I have this:

 map.namespace :admin do |admin|
       admin.resources :galleries do |galleries|
          galleries.resources :gallery_images, :as=>'images'
       end
 end

rake routes shows the route created like this:

 admin_gallery GET    /admin/galleries/:id

and when I go to this url in my browser:

http://192.168.2.2:3000/admin/galleries/11

I get this error:

Unknown action
No action responded to 11

But I would have expected it to use the show action/view, what am I doing wrong?

Routes higher up in the file can interfere with this, and did. Tim Snowhite's comment was correct.

删除尾部斜杠,它应该适合你

http://192.168.2.2:3000/admin/galleries/11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM