def devise_scope(scope)
      constraint = lambda do |request|
        request.env["devise.mapping"] = Devise.mappings[scope]
        true
      end

      constraints(constraint) do
        yield
      end
    end
def devise_scope(scope)
      constraint = lambda do |request|
        request.env["devise.mapping"] = Devise.mappings[scope]
        true
      end

      constraints(constraint) do
        yield
      end
    end
Sets the devise scope to be used in the controller. If you have custom routes,
 you are required to call this method (also aliased as :as) in order to specify
 to which controller it is targeted.

   as :user do
     get "sign_in", to: "devise/sessions#new"
   end

 Notice you cannot have two scopes mapping to the same URL. And remember, if
 you try to access a devise controller without specifying a scope, it will
 raise ActionNotFound error.

 Also be aware of that 'devise_scope' and 'as' use the singular form of the
 noun where other devise route commands expect the plural form. This would be a
 good and working example.

  devise_scope :user do
    get "/some/route" => "some_devise_controller"
  end
  devise_for :users

 Notice and be aware of the differences above between :user and :users