Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2.1 Routing error #64

Open
xxninjabunnyxx opened this issue Feb 10, 2016 · 7 comments
Open

3.2.1 Routing error #64

xxninjabunnyxx opened this issue Feb 10, 2016 · 7 comments

Comments

@xxninjabunnyxx
Copy link

I"m getting a
ActionController::RoutingError (No route matches [GET] "/users/1.json")

I have tried
curl -H 'Accept: application/api.bluemage.systems.v1' 'http://10.0.0.11:3000/users/1.json'

curl -H 'Accept: application/api.bluemage.systems.v1' 'http://10.0.0.11:3000/users/1'

curl -H 'Accept: application/api.bluemage.systems.v1' http://10.0.0.11:3000/users/1

and none of them work, the route shows up with rake routes.

@ghost
Copy link

ghost commented Feb 10, 2016

Mind showing us what your routes file looks like, as well as the output from rake routes?

@kurenn
Copy link
Owner

kurenn commented Feb 12, 2016

Is the devise_for :users line before the api namespace?

@OxenBoxen
Copy link

OxenBoxen commented Jun 7, 2016

It's not working for me either, here is my command: "curl -H 'Accept: application/application/vnd.marketplace.v1' http://api.market_place_api.dev/users/1" . I have devise_for :users before the api namespace

Here is my routes.rb:

MarketPlaceApi::Application.routes.draw do

devise_for :users

namespace :api, defaults: { format: :json}, constraints: { subdomain: 'api' }, path: '/' do

scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do 

    # list resources
    resources :users, :only => [:show]

end

end

end

@ghost
Copy link

ghost commented Jun 7, 2016

Any errors being produced? Do you see the connection being attempted from your rails console?

@kurenn
Copy link
Owner

kurenn commented Feb 12, 2017

@OxenBoxen is there any update on this? were you able to solved it?

@fabOnReact
Copy link

fabOnReact commented Oct 26, 2017

I have the same problem too..

curl: (7) Failed to connect to api.market_place_api.dev port 80: Connection refused

this is my route file

MarketPlaceApi::Application.routes.draw do
  # Api definition
  namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/'  do
    scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
      resources :users, :only => [:show]
    end
  end

  devise_for :users
end

this is my curl command
curl -H 'Accept: application/application/vnd.marketplace.v1' http://api.market_place_api.dev/users/1

also, my main question.. can we do this without actually starting a server at http://api.market_place_api.dev?

thanks

@fabOnReact
Copy link

fabOnReact commented Nov 4, 2017

I was able to make this work based on the following answer from Phanindra

To use localhost:3000/api/v1/users/1 change routes.rb to this

namespace :api, defaults: { format: :json } do
namespace :v1 do
devise_for :users
resources :users, :only => [:show]
end
end

later I try to use the namespaces as in the guide, but right now it is not my priority

I do the following curl command and I receive the json response,

curl 'http://0.0.0.0:3000/api/v1/users/1'
{"id":1,"email":"example@marketplace.com","created_at":"2017-10-26T13:54:18.343Z","updated_at":"2017-10-26T13:54:18.343Z"}

I have a server running on localhost:3000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants