Sha256: 0ae5f30817e3549f7f3e2656831624024d86ddb08c3959b4d52fa911e3fa5878

Contents?: true

Size: 1009 Bytes

Versions: 3

Compression:

Stored size: 1009 Bytes

Contents

class AttachmentGenerator < Rails::Generator::Base
  default_options :skip_migration => false

  def manifest
    record do |m|
      unless options[:skip_migration]
        m.migration_template("migration.rb", "db/migrate", :migration_file_name => "create_attachments")
      end
      m.append("config/routes.rb", "    backend.resources :attachments, :collection => { :order => :post }", "map.namespace(:backend) do |backend|")
      m.directory('app/controllers/backend')
      m.directory('app/models')
      m.template('model.rb', 'app/models/attachment.rb')
      m.template('controller.rb', 'app/controllers/backend/attachments_controller.rb')
      m.readme "../REMEMBER"
    end
  end


  protected
    def banner
      "Usage: #{$0} attachment [--skip-migration]"
    end

    def add_options!(opt)
      opt.separator ''
      opt.separator 'Options:'
      opt.on("--skip-migration",
             "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lipsiadmin-5.1.9 lipsiadmin_generators/attachment/attachment_generator.rb
lipsiadmin-5.1.8 lipsiadmin_generators/attachment/attachment_generator.rb
lipsiadmin-5.1.7 lipsiadmin_generators/attachment/attachment_generator.rb