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

Rails engine (api only) - undefined method `mount_devise_token_auth_for' for #<ActionDispatch::Routing::Mapper: #777

Closed
adonespitogo opened this issue Nov 26, 2016 · 4 comments

Comments

@adonespitogo
Copy link

I have a problem with running a rails engine in the host application. My integration tests pass but when I mount it in the host application, can't start the server due to the above error. Any idea?

Here's my routes:

Rails.application.routes.draw do

  root to: 'web_base#index'

  # ng2 html5 pushState routes
  get 'app', to: 'web_base#app'
  get 'app/*ngroute', to: 'web_base#app'

  mount_devise_token_auth_for 'User', at: 'auth'

  namespace :api, defaults: { format: :json } do


    resource :user
    resources :boards do
      resources :posts do
        resources :comments, only: [:index, :create, :update, :destroy]
      end
    end

    post '/api/share/board/', to: 'share_board#index', as: 'share_board'
    get  '/api/users/search', to: 'users#search', as: 'user_search'


  end

end

My gemspec

  s.add_dependency "rails", "~> 5.0.0", ">= 5.0.0.1"
  s.add_dependency "active_model_serializers"
  s.add_dependency "rack-cors"
  s.add_dependency "kaminari"
  s.add_dependency "api-pagination"
  s.add_dependency "devise_token_auth"
  s.add_dependency "omniauth"

Gemfile

source 'https://rubygems.org'
gemspec
gem "rails", "~> 5.0.0", ">= 5.0.0.1"
gem "active_model_serializers"
gem "rack-cors"
gem "kaminari"
gem "api-pagination"
gem 'devise_token_auth'
gem 'omniauth'

Error log:

[adones@Omars-imac-2 test_unsakini]$ rails s
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Exiting
/home/adones/Projects/UNSAKINI/unsakini/config/routes.rb:9:in `block in <top (required)>': undefined method `mount_devise_token_auth_for' for #<ActionDispatch::Routing::Mapper:0x00564862b63568> (NoMethodError)
@etagwerker
Copy link

@adonespitogo Did you try requiring the gem in routes.rb with something like require 'devise_token_auth'?

@zachfeldman
Copy link
Contributor

Possible workaround posted by @etagwerker (thanks!) Closing for now.

@masroorhussainv
Copy link

@etagwerker, thanks. your solution works.

@udit99
Copy link

udit99 commented Aug 18, 2021

👋 Faced the same issue and the fix worked. Just wondering, is this something that should be in the docs, or better yet, in the generator? Or is it more complicated than that?

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

5 participants