Sha256: cc35a21e79efdda319624197406980ca734cebfcd4403cfadb1bae544f20d569

Contents?: true

Size: 1.02 KB

Versions: 25

Compression:

Stored size: 1.02 KB

Contents

require 'rails/generators/named_base'

module Errdo
  module Generators
    class ErrdoGenerator < Rails::Generators::NamedBase

      desc "Creates the database objects for error logging"

      include Rails::Generators::ResourceHelpers
      namespace "errdo"

      argument :name, type: 'string', default: "error"

      hook_for :orm do |instance, controller|
        instance.invoke controller, [instance.name]
      end

      def add_error_name_to_initializer
        inject_into_file 'config/initializers/errdo.rb', before: "\nend" do
          <<-TEXT


  # This is the name of the class inside your application that the exceptions are stored as.
  # Exceptions are a reserved class name.
  #
  # If you want to rename it, make sure you also change the migration that comes with the gem.
  # Setting this to nil means that errors won't be tracked in the database
  # Note: The model name "{name}_instance" should also be free
  #
  config.error_name = :#{file_name.pluralize}
          TEXT
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
errdo-0.12.14 lib/generators/errdo/errdo_generator.rb
errdo-0.12.13 lib/generators/errdo/errdo_generator.rb
errdo-0.12.12 lib/generators/errdo/errdo_generator.rb
errdo-0.12.11 lib/generators/errdo/errdo_generator.rb
errdo-0.12.10 lib/generators/errdo/errdo_generator.rb
errdo-0.12.9 lib/generators/errdo/errdo_generator.rb
errdo-0.12.8 lib/generators/errdo/errdo_generator.rb
errdo-0.12.7 lib/generators/errdo/errdo_generator.rb
errdo-0.12.6 lib/generators/errdo/errdo_generator.rb
errdo-0.12.5 lib/generators/errdo/errdo_generator.rb
errdo-0.12.4 lib/generators/errdo/errdo_generator.rb
errdo-0.12.3 lib/generators/errdo/errdo_generator.rb
errdo-0.12.2 lib/generators/errdo/errdo_generator.rb
errdo-0.12.1 lib/generators/errdo/errdo_generator.rb
errdo-0.12.0 lib/generators/errdo/errdo_generator.rb
errdo-0.11.6 lib/generators/errdo/errdo_generator.rb
errdo-0.11.5 lib/generators/errdo/errdo_generator.rb
errdo-0.11.4 lib/generators/errdo/errdo_generator.rb
errdo-0.11.3 lib/generators/errdo/errdo_generator.rb
errdo-0.11.2 lib/generators/errdo/errdo_generator.rb