如何在Ruby on Rails视图中路由子文件夹?

问题描述:

任何人都可以阐明如何路由子文件夹的.html.erb文件吗?这样放置:

Can anyone please shed some light on how to route your sub-folder's .html.erb files?? which is placed like this:

view/pages/en/index.html.erb

并为此路由,我正在route.rb上执行以下操作

and to route this i am doing following things on route.rb

match ':lang/index', :to => 'pages/en#index'

,对于链接代码,我将其放在标题上

and for a link code, I have this on the header

<%= link_to "Home", index_path %>

我得到的错误是

 Routing Error
 uninitialized constant Pages

路线:

AFAIK,无法路由到视图。您可以将URL路由到控制器的操作。该操作负责呈现视图。

AFAIK, There is no way to route to a view. You can route an URL to a controller's action. That action is responsible for rendering the views.

您可以使用命名空间路由将资源放在子文件夹中。

you can use namespaced routing to put the resources in the sub folder.

...

我想写的已经由@TuteC编写的内容。只需点击该链接,是的,您可以按照他的解释开箱即用。

What i wanted to write already written by @TuteC. Just follow that link and yes you can get language specific thing out of box as he explained.