Class: ErrorLens::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ErrorLens::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/error_lens/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
13 14 15 16 |
# File 'lib/generators/error_lens/install/install_generator.rb', line 13 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end |
Instance Method Details
#copy_migration ⇒ Object
18 19 20 21 22 23 |
# File 'lib/generators/error_lens/install/install_generator.rb', line 18 def copy_migration migration_template( "create_error_lens_tables.rb.tt", "db/migrate/create_error_lens_tables.rb" ) end |
#create_initializer ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/error_lens/install/install_generator.rb', line 29 def create_initializer create_file "config/initializers/error_lens.rb", <<~RUBY ErrorLens.configure do |config| # Error classes to ignore — these will not be recorded # config.ignored_exceptions = %w[ActionController::RoutingError] # Parameter keys to filter from stored data # config.filter_parameters = %w[password token secret credit_card] end RUBY end |
#mount_engine ⇒ Object
25 26 27 |
# File 'lib/generators/error_lens/install/install_generator.rb', line 25 def mount_engine route 'mount ErrorLens::Engine, at: "/error_lens"' end |
#show_readme ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/error_lens/install/install_generator.rb', line 41 def show_readme say "" say "ErrorLens installed!", :green say "" say "Next steps:", :bold say " 1. Run migrations: bundle exec rails db:migrate" say " 2. Start your server and hit /error_lens" say " 3. To protect the route, wrap the mount in your auth constraint:" say "" say " # Devise example:" say " authenticate :user, ->(u) { u.admin? } do" say " mount ErrorLens::Engine, at: \"/error_lens\"" say " end" say "" end |