简体   繁体   中英

Rails mountable engine and devise

I have a mountable rails engine with Devise. When I copy my migrations and run rake db:migrate in the dummy app it works just fine.

But when I use a new rails app, add my engine to the gem file, copy migrations and run rake db:migrate I get this error "uninitialized constant Devise".

I have this in my routes file:

mount Cms::Engine, :at => '/', :as => 'cms'

What am I doing wrong ?

I think you need to explicitly require devise in your engine's engine.rb file.

From the Rails guides :

Note that if you want to immediately require dependencies when the engine is required, you should require them before the engine's initialization. For example:

So just add require 'devise' to the top or your engine.rb .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM