-3

I'm getting a "No route matches" exception in one of my tests (and using curl from the command line) one of my routes (POST /users/confirm). The curl's I've tried are as follows, neither of them work and receive the same exceptions outlined in the below notes:

curl -X POST -H "Content-Type: application/json; version=1" \
   -d '{ user: { "token":"1deb36b4e6a7ba6d9203" } }' \
   http://localhost:3000/appname/users/confirm

curl -X POST -H "Content-Type: application/json; version=1" \
   -d '{ "token":"1deb36b4e6a7ba6d9203" }' \
   http://localhost:3000/appname/users/confirm

enter image description here

My test is as follows. I have config.wrap_parameters = true in my /config/application.rb file...

enter image description here

Here is my User UsersController#confirm action along with my strong params. I params.require(:user).permit(:token) as opposed to simply params.permit(:token) because, as stated above, I have config.wrap_parameters = true in my /config/application.rb file...

enter image description here

This is my route entry...

enter image description here

Here is the output from rails routes (app name removed)...

enter image description here

I have config.wrap_parameters = true in my /config/application.rb file...

enter image description here

Oddly enough, if I change my params in my test to post :confirm, params: { token: @user.confirmation_token }, I get the following error instead: enter image description here

At a loss. Any thoughts?

gangelo
  • 2,616
  • 3
  • 24
  • 36
  • 2
    According to the results of `rails routes` your path is incomplete. It expects something after `/confirm`. For example, `/confirm/username` will be a valid route. – Yaw Boakye Oct 04 '17 at 13:21
  • 1
    Please dont post an images, post actual text. – Зелёный Oct 04 '17 at 13:21
  • @Зелёный 6 and 1/2 dozen to another. Some people like images. Sheez. – gangelo Oct 04 '17 at 13:27
  • @YawBoakye thank you, it appears I didn't need the :token param after all, you helped me on my way rather than worrying about me posting images. – gangelo Oct 04 '17 at 13:57

1 Answers1

0

It turns out I didn't need :token in my route after all. Changed it to this, and all is well:

post '/appname/users/confirm/', to: 'users#confirm', as: 'appname_users_confirm'

gangelo
  • 2,616
  • 3
  • 24
  • 36