首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

rails 异常“No route matches”

2012-07-15 
rails 错误“No route matches”转载:http://xyz920z.blog.163.com/blog/static/60703320082982553644/ 这是

rails 错误“No route matches”

转载:http://xyz920z.blog.163.com/blog/static/60703320082982553644/

这是像我一样初学者能遇到的错误,有的人甚至在ruby on rails 的第一个程序hello world运行时就出现这类错误,非常郁闷,解决的方法是编辑一下config文件夹下的routes.rb,如可以修改成这样(红色字体部分):

ActionController::Routing::Routes.draw do |map|
? # The priority is based upon order of creation: first created -> highest priority.

? # Sample of regular route:
? #?? map.connect 'products/:id', :controller => 'catalog', :action => 'view'
? # Keep in mind you can assign values other than :controller and :action

? # Sample of named route:
? #?? map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
? # This route can be invoked with purchase_url(:id => product.id)

? # Sample resource route (maps HTTP verbs to controller actions automatically):
? #?? map.resources :products

? # Sample resource route with options:
? #?? map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

? # Sample resource route with sub-resources:
? #?? map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

? # Sample resource route within a namespace:
? #?? map.namespace :admin do |admin|
? #???? # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
? #???? admin.resources :products
? #?? end

? # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
? # map.root :controller => "welcome"

? # See how all your routes lay out with "rake routes"
? map.connect '',:controller=>"index",:action=>"index"
?
? # Install the default routes as the lowest priority.
? map.connect ':controller/:action/:id'
? map.connect ':controller/:action/:id.:format'
end

?

热点排行