Skip to content

Chapter 6 ActionController::UrlGenerationError: #91

@tee

Description

@tee

When running the test for the product, or in my case departure, I am getting this error:

Failure/Error: post "/users/#{user.id}/departures", params: { departure: @departure_attributes.merge(user_id: user.id, location_id: location.id) }, format: :json
ActionController::UrlGenerationError:
No route matches {:action=>"/users/1070/departures", :controller=>"api/v1/departures", :departure=>{:uuid=>"0e1641c2-3031-4079-8132-74499350a3b8", :user_id=>1070, :location_id=>492}, :format=>:json}

Even though I have this in my routes file.

resources :users, :only => [:show, :create, :update, :destroy] do
    resources :departures, :only => [:create]
end

Has anybody else experienced this issue? If so, how did you resolve it?

This is the route that appears in my terminal:

api_user_departures POST   /users/:user_id/departures(.:format)                                                     api/v1/departures#create {:subdomain=>"api", :format=>:json}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions