我一直在尝试从外部读取导轨路由并且失败得很惨。我相信我想做的是非常基本的,但无论出于何种原因我都无法弄清楚。这是情况。
我希望我的网址读取 www.example.com/maps 而不是他们现在正在做的事情 www.example.com/maps/map 这是控制器然后查看名称。
我的路线如下所示。
homepages GET /homepages(.:format) homepages#index
POST /homepages(.:format) homepages#create
new_homepage GET /homepages/new(.:format) homepages#new
edit_homepage GET /homepages/:id/edit(.:format) homepages#edit
homepage GET /homepages/:id(.:format) homepages#show
PUT /homepages/:id(.:format) homepages#update
DELETE /homepages/:id(.:format) homepages#destroy
root / homepages#index
maps GET /maps(.:format) maps#index
POST /maps(.:format) maps#create
new_map GET /maps/new(.:format) maps#new
edit_map GET /maps/:id/edit(.:format) maps#edit
map GET /maps/:id(.:format) maps#show
PUT /maps/:id(.:format) maps#update
DELETE /maps/:id(.:format) maps#destroy
work_index GET /work(.:format) work#index
POST /work(.:format) work#create
new_work GET /work/new(.:format) work#new
edit_work GET /work/:id/edit(.:format) work#edit
work GET /work/:id(.:format) work#show
PUT /work/:id(.:format) work#update
DELETE /work/:id(.:format) work#destroy
contact_index GET /contact(.:format) contact#index
我尝试做类似资源:maps, :path => '' 但是当我访问我的网站时,url 看起来是一样的。那是因为我视图上的代码看起来像
<li class="current_page_item"><%= link_to "Bio", :controller => :homepages, :action => :index %></li>
<li><%= link_to "Work", :controller => :work, :action => :experience %></li>
<li><%= link_to "Map", :controller => :maps, :action => :map %></li>
<li><%= link_to "Contact", :controller => :contact, :action => :email %></li>
还是因为我的路线错了?
我的路线文件目前看起来像
Me::Application.routes.draw do
resources :homepages
root :to => 'homepages#index'
resources :maps
resources :work
resources :contact
resources :media
感谢您的帮助!