class DeviseLdapMultipleGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) argument :user_model, :type => :string, :default => "user", :desc => "Model to update" # 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/#{user_model}.yml" end def update_user_model gsub_file "app/models/#{user_model}.rb", /:database_authenticatable/, ":ldap_authenticatable" inject_into_class "app/models/#{user_model}.rb", user_model.capitalize.constantize do "\n include DeviseLDAPMultiple\n" end end end