module DeviseLdapMultiple class InstallGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) # ToDo: Request user input to use a scope that already exists, or make it a parameter to pass into the generator def create_ldap_config copy_file "default.yml", "config/ldap/default.yml" end def create_default_devise_settings inject_into_file "config/initializers/devise.rb", default_devise_settings, :after => "Devise.setup do |config|\n" end def update_application_controller inject_into_class "app/controllers/application_controller.rb", ApplicationController, rescue_from_exception if options.add_rescue? end private def default_devise_settings settings = <<-eof # ==> Devise LDAP Multiple configuration config.ldap_default_scope = 'default' eof settings end def rescue_from_exception <<-eof rescue_from DeviseLdapMultiple::LdapException do |exception| render :text => exception, :status => 500 end eof end end end