문제

In Rails, how can I place views in sub directories / sub folders (just to organize them), and still have them properly routed/rendered?


I want to organize some of my views under the namespace of another view. All views are under one controller.

I want

www.custom.com/controller/action/

to show the action.html view.

I want to use this url

www.custom.com/controller/action/sub_action

instead of

www.custom.com/controller/sub_action

Both are sibling actions and views under the same controller. I wish for action to render a page, and also be used as a namespace for other views.

I don't want/need to make another controller or resource.

How do I do this?

도움이 되었습니까?

해결책

When you render in your controller, you can specify which view you want (if it's not in the conventional place for any reason).

render 'controller/action/sub_action'

or even:

render 'some_other_controller/action/sub_action'

Checkout the Rails guides on rendering

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top