Skip to content

Instantly share code, notes, and snippets.

@johnbeynon
Last active December 25, 2015 04:09
Show Gist options
  • Save johnbeynon/6915478 to your computer and use it in GitHub Desktop.
Save johnbeynon/6915478 to your computer and use it in GitHub Desktop.
Devise strategy to bypass entering a password for development mode

This is a simple devise strategy that allows you to bypass the need to enter a password when a site is runnning in development mode.

lib\devise\strategies\development.rb

module Devise
  module Strategies
    class Development < Authenticatable
      def authenticate!
        resource = mapping.to.find_for_database_authentication(authentication_hash)
        return fail(:not_found_in_database) unless resource

        success!(resource)
      end
    end
  end
end

Edit config\initializers\devise.rb and add the following before the existing close end

  ...

  config.warden do |manager|
    if Rails.env.development?
      manager.strategies.add(:development,Devise::Strategies::Development)
      manager.default_strategies(:scope => :user).unshift :development
    end
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment