新手,刚接触 rails。 路由器真很让我郁闷。。。
在 routes.rb
get "check" => "registrations#check"
添加路由。
然后
class RegistrationsController < Devise::RegistrationsController
类中有方法
def check
ret = User.find_by_username(params[:user["email"]]);
render :text =>ret.to_json;
end
然后访问 http://localhost:3000/check
就一直提示:
AbstractController::ActionNotFound at /check
Could not find devise mapping for path "/check".
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
get "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
无法找到 action /check
————————————————
谢谢。