Search code examples
ruby-on-railsruby-on-rails-3deviserubygemsload-path

change default load path for devise views and controller


This is my gem file gem 'devise', '1.5.2' and this is my routes.rb devise_for :users This is what i learnt: Initially the controller,views were loading from vender/gems/1.91/ruby/devise 1.5.2 so what i did i added modified the app structure to app/controllers/devise/(and copied all controller from vender/gems/1.91/ruby/devise 1.5.2/app/controllers) as well as did the same to views because everytime the views were loading from vendor so i when i added devise folder ,it was loading from app/views/users/ instead of vendor. BUT just now i did bundle install and everything is again the same and loading from vendor...i didnt understand why bundle install change this. so what changes do i need to do so that next time my changes doesnt get lost. all i want is to load *devise views/controllers from myapp/app/controllers and myapp/app/views*rather than from vendor/bundle/gems/1.91/ruby/gems/devise 1.5.2 where i load the gems for my app.pls advise??** Did bundle install changed everyting???how to prevent this in future??


Solution

  • It is all Here

    Don't copy manually, use the generator

    rails generate devise:views
    

    All needed views will be generated under app/views/devise

    As for the controllers, create them under app/controllers

    class RegistrationsController < Devise::RegistrationsController
    
    end
    

    or

    class SessionsController < Devise::SessionsController
    
    end
    

    and change routes.rb to point them:

    devise_for :admins, :controllers => { :sessions => "<YOUR_SESSION_CONTROLLER>", :registrations =>  "<YOUR_REGISTRATION_CONTROLLER>"}