Sha256: 3791755dec6f0d54c03b4ff4d2487b3445ac9a621855ceb743bd96d234755a68

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 KB

Contents

module Initial
  class DeviseGenerator < Rails::Generators::Base
    source_root File.expand_path("../templates", __FILE__)

    def add
      gem 'devise'
      gem 'cancancan'

      gem_group :development do
        gem 'letter_opener'
      end

      Bundler.with_clean_env do
        run "bundle install"
      end

      generate 'cancan:ability'
      generate 'devise:install'
      generate 'devise:views'

      insert_into_file "config/environments/development.rb", before: "end\n" do
%Q{
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  config.action_mailer.delivery_method = :letter_opener

}
      end

      insert_into_file 'app/controllers/application_controller.rb', after: "protect_from_forgery with: :exception\n" do
%Q{
  before_action :authenticate_user!

  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, alert: exception.message
  end

}
      end

      copy_file 'devise/devise.ru.yml', 'config/locales/devise.ru.yml'

      model = ask "Type MODEL to bootstrap devise:"
      generate "devise #{model}"

      with_oauth = ask 'Add oauth? (y/n)'
      generate 'devise_oauth' if with_oauth =~ /y/
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
teleporter-1.2.4 lib/generators/initial/devise.rb
teleporter-1.2.3 lib/generators/initial/devise.rb
teleporter-1.2.2 lib/generators/initial/devise.rb
teleporter-1.2.1 lib/generators/initial/devise.rb
teleporter-1.1.1 lib/generators/initial/devise.rb
teleporter-1.1.0 lib/generators/initial/devise.rb
teleporter-1.0.2 lib/generators/initial/devise.rb
teleporter-1.0.1 lib/generators/initial/devise.rb
teleporter-1.0.0 lib/generators/initial/devise.rb
teleporter-0.1.0 lib/generators/initial/devise.rb
teleporter-0.0.34 lib/generators/initial/devise.rb
teleporter-0.0.33 lib/generators/initial/devise.rb
teleporter-0.0.32 lib/generators/initial/devise.rb
teleporter-0.0.31 lib/generators/initial/devise.rb
teleporter-0.0.30 lib/generators/initial/devise.rb
teleporter-0.0.29 lib/generators/initial/devise.rb