我在尝试查看网页时遇到此错误。
ActionView :: Template ::错误(无路由 匹配{:controller =>“classifieds”, :action =>“edit”,:id =>#}): 40:<%= h classified.category.name %GT; 41:<%= h classified.subcategory.name %GT; 42:<%= h classified.status%> 43:<%= link_to“编辑”, edit_classified_path(分类)%> 44:<%= link_to'Destroy',分类, :confirm => “你确定吗?”,方法 => :删除%> 45:<%= check_box_tag'删除[id] []', classified.id,false%> 46:
路由文件
Rails3::Application.routes.draw do
resources :main, :categories, :cities, :users, :subcategories, :classifieds
resource :user
root :to => 'main#index'
match ':controller(/:action(/:id(.:format)))'
# route for simple captcha
match '/simple_captcha/:action', :controller => 'simple_captcha'
#admin logout
match '/logout', :controller=>'users', :action=>'destroy'
match '/login', :controller=>'users', :action=>'show'
match '/adminsearch', :controller=>'classifieds', :action=>'adminsearch'
#search
match '/mainsearch', :controller=>'main', :action=>'mainsearch'
match '/:permalink_1/categorysearch', :controller=>'main', :action=>'categorysearch'
match '/contactadvertiser', :controller=>'main', :action=>'contactadvertiser'
#city page
match '/:permalink_1', :controller => 'main', :action => 'city'
match '/edit', :controller => 'cities', :action => 'edit'
#activate, edit classifieds
match '/activate/:activation_code', :controller => 'main', :action => 'activate'
match '/edit/:activation_code', :controller => 'classifieds', :action => 'edit'
match '/update/:activation_code', :controller => 'classifieds', :action => 'update'
match '/delete/:activation_code', :controller => 'classifieds', :action => 'destroy'
match '/classifieds/multidelete', :controller=>'classifieds', :action=>'delete_multiple'
#category page
match '/:permalink_1/:permalink_2', :controller => 'main', :action => 'category'
#ad page
match '/:permalink_1/:permalink_2/:permalink_3', :controller => 'classifieds', :action => 'show'
end
rake routes:
main_index GET /main(.:format) {:controller=>"main", :action=>"index"}
POST /main(.:format) {:controller=>"main", :action=>"create"}
new_main GET /main/new(.:format) {:controller=>"main", :action=>"new"}
edit_main GET /main/:id/edit(.:format) {:controller=>"main", :action=>"edit"}
main GET /main/:id(.:format) {:controller=>"main", :action=>"show"}
PUT /main/:id(.:format) {:controller=>"main", :action=>"update"}
DELETE /main/:id(.:format) {:controller=>"main", :action=>"destroy"}
categories GET /categories(.:format) {:controller=>"categories", :action=>"index"}
POST /categories(.:format) {:controller=>"categories", :action=>"create"}
new_category GET /categories/new(.:format) {:controller=>"categories", :action=>"new"}
edit_category GET /categories/:id/edit(.:format) {:controller=>"categories", :action=>"edit"}
category GET /categories/:id(.:format) {:controller=>"categories", :action=>"show"}
PUT /categories/:id(.:format) {:controller=>"categories", :action=>"update"}
DELETE /categories/:id(.:format) {:controller=>"categories", :action=>"destroy"}
cities GET /cities(.:format) {:controller=>"cities", :action=>"index"}
POST /cities(.:format) {:controller=>"cities", :action=>"create"}
new_city GET /cities/new(.:format) {:controller=>"cities", :action=>"new"}
edit_city GET /cities/:id/edit(.:format) {:controller=>"cities", :action=>"edit"}
city GET /cities/:id(.:format) {:controller=>"cities", :action=>"show"}
PUT /cities/:id(.:format) {:controller=>"cities", :action=>"update"}
DELETE /cities/:id(.:format) {:controller=>"cities", :action=>"destroy"}
users GET /users(.:format) {:controller=>"users", :action=>"index"}
POST /users(.:format) {:controller=>"users", :action=>"create"}
new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"}
edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"}
user GET /users/:id(.:format) {:controller=>"users", :action=>"show"}
PUT /users/:id(.:format) {:controller=>"users", :action=>"update"}
DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
subcategories GET /subcategories(.:format) {:controller=>"subcategories", :action=>"index"}
POST /subcategories(.:format) {:controller=>"subcategories", :action=>"create"}
new_subcategory GET /subcategories/new(.:format) {:controller=>"subcategories", :action=>"new"}
edit_subcategory GET /subcategories/:id/edit(.:format) {:controller=>"subcategories", :action=>"edit"}
subcategory GET /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"show"}
PUT /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"update"}
DELETE /subcategories/:id(.:format) {:controller=>"subcategories", :action=>"destroy"}
classifieds GET /classifieds(.:format) {:controller=>"classifieds", :action=>"index"}
POST /classifieds(.:format) {:controller=>"classifieds", :action=>"create"}
new_classified GET /classifieds/new(.:format) {:controller=>"classifieds", :action=>"new"}
edit_classified GET /classifieds/:id/edit(.:format) {:controller=>"classifieds", :action=>"edit"}
classified GET /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"show"}
PUT /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"update"}
DELETE /classifieds/:id(.:format) {:controller=>"classifieds", :action=>"destroy"}
POST /user(.:format) {:controller=>"users", :action=>"create"}
GET /user/new(.:format) {:controller=>"users", :action=>"new"}
GET /user/edit(.:format) {:controller=>"users", :action=>"edit"}
GET /user(.:format) {:controller=>"users", :action=>"show"}
PUT /user(.:format) {:controller=>"users", :action=>"update"}
DELETE /user(.:format) {:controller=>"users", :action=>"destroy"}
root /(.:format) {:controller=>"main", :action=>"index"}
/:controller(/:action(/:id(.:format)))
/simple_captcha/:action(.:format) {:controller=>"simple_captcha"}
logout /logout(.:format) {:controller=>"users", :action=>"destroy"}
login /login(.:format) {:controller=>"users", :action=>"show"}
adminsearch /adminsearch(.:format) {:controller=>"classifieds", :action=>"adminsearch"}
mainsearch /mainsearch(.:format) {:controller=>"main", :action=>"mainsearch"}
/:permalink_1/categorysearch(.:format) {:controller=>"main", :action=>"categorysearch"}
contactadvertiser /contactadvertiser(.:format) {:controller=>"main", :action=>"contactadvertiser"}
/:permalink_1(.:format) {:controller=>"main", :action=>"city"}
edit /edit(.:format) {:controller=>"cities", :action=>"edit"}
/activate/:activation_code(.:format) {:controller=>"main", :action=>"activate"}
/edit/:activation_code(.:format) {:controller=>"classifieds", :action=>"edit"}
/update/:activation_code(.:format) {:controller=>"classifieds", :action=>"update"}
/delete/:activation_code(.:format) {:controller=>"classifieds", :action=>"destroy"} classifieds_multidelete /classifieds/multidelete(.:format) {:controller=>"classifieds", :action=>"delete_multiple"}
/:permalink_1/:permalink_2(.:format) {:controller=>"main", :action=>"category"}
/:permalink_1/:permalink_2/:permalink_3(.:format) {:controller=>"classifieds", :action=>"show"}
simple_captcha /simple_captcha/:id(.:format) {:controller=>"simple_captcha", :action=>"show"}
答案 0 :(得分:0)
你想这样做:
<%= link_to "Edit", edit_classified_path(:activation_code => classified)%>
或将您的routes.rb编辑为:
match '/edit/:id', :controller => 'classifieds', :action => 'edit'
答案 1 :(得分:0)
你的路线非常多余且矛盾。首先,尝试摆脱全能路线:
match ':controller(/:action(/:id(.:format)))'
因为如果您使用的是RESTful路由,则不应该使用它。如果这没有帮助,请告诉我,我会相应地更新我的答案。
此外,所有match
路线都不正确。他们应该遵循这样的模式:
match '/my_controller/:id' => 'my_controller#action'