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

minor error in README with regard to usage alongside Devise #745

Closed
edwardmp opened this issue Sep 29, 2016 · 7 comments · Fixed by #1129
Closed

minor error in README with regard to usage alongside Devise #745

edwardmp opened this issue Sep 29, 2016 · 7 comments · Fixed by #1129

Comments

@edwardmp
Copy link

Hi,

I noticed the README gives the following snippet of code (https://github.com/lynndylanhurley/devise_token_auth#configinitializersdevise_token_authrb):

DeviseTokenAuth.setup do |config|
  # config.enable_standard_devise_support = false
end

This does not make sense to me. Shouldn't this be:

DeviseTokenAuth.setup do |config|
    config.enable_standard_devise_support = true
end

If this is a really a mistake I'll create a pull request but I'm not sure at this point yet.

@edwardmp edwardmp changed the title minor error in README with regard to using alongside Devise minor error in README with regard to usage alongside Devise Sep 29, 2016
@gbrl
Copy link

gbrl commented Sep 30, 2016

I was just about to post about this. It seems the instructions imply you should set that value to true, but the example code has that line commented out. I was confused as well.

@gbrl
Copy link

gbrl commented Sep 30, 2016

Also, when I follow the instructions, I get a conflicting routes error:

ArgumentError: Invalid route name, already in use: 'new_user_session'
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created

Here are my routes:

Rails.application.routes.draw do
  devise_for :users
  apipie

  scope '/api' do
    mount_devise_token_auth_for 'User', at: 'auth'
    mount_devise_token_auth_for 'Admin', at: 'admin_auth'

    resources :user do
      resource :profile, only: [:new, :create, :update]
    end
  end
end

@gbrl
Copy link

gbrl commented Sep 30, 2016

I don't know if this really solves the issue, but to avoid having duplicate route names, I was able to solve it by configuring my routes.rb like this:

  resources :devise do
    devise_for :users
  end

This way you get "new_user_devise_session" for devise, and "new_user_session" for devise_token_auth

@KjellMorgenstern
Copy link

Replace
scope '/api' do
with
namespace :api do
as in the documentation. This also resolves the routing conflict.

@edwardmp
Copy link
Author

@KjellMorgenstern @gbrl
Yup, that's what I did eventually

@KaraAJC
Copy link

KaraAJC commented Feb 9, 2017

So, to clarify, the config file SHOULD or SHOULD NOT be changed to:

DeviseTokenAuth.setup do |config|
    config.enable_standard_devise_support = true
end

@zachfeldman
Copy link
Contributor

@lynndylanhurley this seems like a fairly simple one to close if we have your blessing for the above fix to the README? I can update it if so.

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

Successfully merging a pull request may close this issue.

5 participants