How to set up a route on rails?

On my .rb routes, I have this:

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

rake routes show a route created as follows:

 admin_gallery GET    /admin/galleries/:id

and when I go to this URL in the browser:

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

I get this error:

Unknown action
No action responded to 11

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

+3
source share
2 answers

The routes above in the file may interfere with this and have done so. Tim Snowhite's comment was correct.

+2
source

Remove the trailing slash and it should work for you

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

Source: https://habr.com/ru/post/1740702/


All Articles