我有一个奇怪的问题。我正在使用带有脚手架的导轨来创建 CRUD 和其他东西。然后我添加了一个名为 cnt 的函数,它应该给我表格条目的计数。例如 Albums.count 用于密码。但是今天早上,整个路由都指向那个页面。当我尝试访问 xxx/elements 时,我被链接到了 /cntalbums。
看起来像一个路由的东西 - 这是我的 routes.rb:
Something::Application.routes.draw do
resources :albums
get "home/index"
resources :elements
root :to => 'home#index'
end
就这样。我删除了cnt的视图,我删除了位于albums_controller中的方法。所以没有 friggn 点剩下,在哪里实现 cnt。但似乎每个 GET 都链接到该页面。我在我的日志中得到了这个:
Started GET "/albums" for xxxx at Fri Oct 05 09:54:42 +0200 2012
Processing by AlbumsController#cnt as HTML
Parameters: {"cntalbums"=>"albums"}
Completed 500 Internal Server Error in 47ms
ActionView::MissingTemplate (Missing template albums/cnt, application/cnt with {:formats=>[:html], :locale=>[:en], :handlers=>[:erb, :builder]}. Searched in:
* "/kunden/nnax.de/webseiten/entwicklung/poezy/app/views"
):
app/controllers/albums_controller.rb:18:in `cnt'
我有:
match ':cntalbums' => 'albums#cnt', :as => 'cnt_albums', :via => :get
前; 但我已经删除了。所以我没有任何线索,为什么我看不到我的专辑、元素等。最后: rake routes 给了我:
albums GET /albums(.:format) albums#index
POST /albums(.:format) albums#create
new_album GET /albums/new(.:format) albums#new
edit_album GET /albums/:id/edit(.:format) albums#edit
album GET /albums/:id(.:format) albums#show
PUT /albums/:id(.:format) albums#update
DELETE /albums/:id(.:format) albums#destroy
elements GET /elements(.:format) elements#index
POST /elements(.:format) elements#create
new_element GET /elements/new(.:format) elements#new
edit_element GET /elements/:id/edit(.:format) elements#edit
element GET /elements/:id(.:format) elements#show
PUT /elements/:id(.:format) elements#update
DELETE /elements/:id(.:format) elements#destroy
home_index GET /home/index(.:format) home#index
root / home#index
所以我的理解很清楚;我想去专辑或元素,它进入了拟合控制器的功能。但它总是试图到达 AlbumsController#cnt
尽管该功能甚至不再存在
任何提示?:/