문제

I am trying to create a nested route like this:

resources :storyboards, path: "" do
  resources :stories, path:""
end

This renders the following path params:

enter image description here


Because the nested route is defined before the parent, Rails is ignoring our /new route for our parent controller. I was wondering if anyone has achieved what we're trying to (using path: "" for nested routes)?

I believe the two fixes would be:

  1. Create separate new route for storyboards controller (to override the other)
  2. Somehow get rails to render the nested routes under the parent

If anyone has experience in this, your insight would be greatly appreciated!

도움이 되었습니까?

해결책

With help from @babar, we managed to fix the error with a small hack:

#config/routes.rb
get "new", to: "storyboards#new"
resources :storyboards, path: "" do
    resources :stories
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top