kurenn / market_place_api

The API on Rails tutorial application
142 stars 68 forks source link

No route matches [POST] "/sessions" #67

Open nikunj0407 opened 8 years ago

nikunj0407 commented 8 years ago

Hi, I am using POSTMAN for making requests to API. When I request sessions#create for sign_in it throws "No route matches [POST] "/sessions"

Following is the output of rake routes

` ```

 new_user_session GET      /users/sign_in(.:format)               devise/sessions#new
            user_session POST     /users/sign_in(.:format)               devise/sessions#create
    destroy_user_session DELETE   /users/sign_out(.:format)              devise/sessions#destroy
 user_omniauth_authorize GET|POST /users/auth/:provider(.:format)        devise/omniauth_callbacks#passthru {:provider=>/(?!)/}
  user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) devise/omniauth_callbacks#(?-mix:(?!))
           user_password POST     /users/password(.:format)              devise/passwords#create
       new_user_password GET      /users/password/new(.:format)          devise/passwords#new
      edit_user_password GET      /users/password/edit(.:format)         devise/passwords#edit
                         PATCH    /users/password(.:format)              devise/passwords#update
                         PUT      /users/password(.:format)              devise/passwords#update
cancel_user_registration GET      /users/cancel(.:format)                devise/registrations#cancel
       user_registration POST     /users(.:format)                       devise/registrations#create
   new_user_registration GET      /users/sign_up(.:format)               devise/registrations#new
  edit_user_registration GET      /users/edit(.:format)                  devise/registrations#edit
                         PATCH    /users(.:format)                       devise/registrations#update
                         PUT      /users(.:format)                       devise/registrations#update
                         DELETE   /users(.:format)                       devise/registrations#destroy
       user_confirmation POST     /users/confirmation(.:format)          devise/confirmations#create
   new_user_confirmation GET      /users/confirmation/new(.:format)      devise/confirmations#new
                         GET      /users/confirmation(.:format)          devise/confirmations#show
            api_sessions POST     /sessions(.:format)                    api/v1/sessions#create {:format=>:json, :subdomain=>"api"}
             api_session DELETE   /sessions/:id(.:format)                api/v1/sessions#destroy {:format=>:json, :subdomain=>"api"}

As I've added subdomain constraint, I am making the POST request to "api.lvh.me:3000/sessions" with email and password as params.

Let me know where I am doing the mistake.
kurenn commented 8 years ago

Try moving the sessions routes above the devise ones