我完全正在使用应用程序直到前一天我开始逐个获得路由错误。 由于调试没有帮助我将routes.rb文件回滚到3周旧版本。在那个时候肯定没有任何错误。但是这没有用。
我仅针对具体行动遇到错误。
1)注销(Devise gem)
http://localhost:3000/lv/users/sign_out
错误=> Couldn't find User with 'id'=sign_out
它指向用户控制器
private
def set_user
@user = User.find(params[:id]) # <= this line !!
end
2)当我尝试使用Acts_as_votable gem能力为模型投票时。 http://localhost:3000/lv/advertisements/145/like
=&gt; No route matches [GET] "/lv/advertisements/145/like"
我的路线档案:
Rails.application.routes.draw do
scope "(:locale)", :locale => /lv|ee|ru/ do
root 'home#index'
get 'advertisements/update_regions' => 'advertisements#update_regions', as: 'update_regions'
resources :replies do
member do
put "like", to: "replies#upvote"
put "dislike", to: "replies#downvote"
end
end
resources :reviews do
member do
put "like", to: "reviews#upvote"
put "dislike", to: "reviews#downvote"
end
end
resources :advertisements do
collection { post :search, to: 'advertisements#index' }
member do
put "like", to: "advertisements#upvote"
put "dislike", to: "advertisements#downvote"
end
end
resources :services
get "/help", to: "help#index"
get "/rules", to: "rules#index"
get "/blacklist", to: "blacklist#index"
devise_for :users
resources :users, only: [:show, :index] do
member do
put "like", to: "users#upvote"
put "dislike", to: "users#downvote"
end
end
resource :user, only: [:edit] do
collection do
patch 'update_password'
end
end
resources :types
resources :feedbacks
resources "men-blacklist", :controller => :men_blacklist, :as => :men_blacklist
resources "girl-blacklist", :controller => :girl_blacklist, :as => :girl_blacklist
get 'sms/receive/', to: 'sms#receive'
get 'girl_blacklist/index'
resources :hours
get 'replies/show'
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
resources :reports
#get "/accept" => 'home#accept_and_redirect'
mount Judge::Engine => '/judge'
end
end
我记不起也许我在错误开始之前安装了一些gem。但情况可能就是这样吗?