Sha256: c261644f66aecdc051ee4eca70739b99a08a3a303f9a2af94f9b994db64a0d15

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Ponytail
  class MigrationsController < ActionController::Base
    layout 'ponytail/application'

    def index
      @migrations = Migration.all
      @current_version = Migration.current_version
    end

    def new
      @migration = Migration.new
    end

    def create
      @migration = Migration.new(migraion_params)

      if @migration.save
        redirect_to :migrations, notice: 'Migration was successfully created.'
      else
        render action: 'new'
      end
    end

    def migrate
      if Migration.migrate
        redirect_to :migrations, notice: 'Migrate was succeed.'
      else
        redirect_to :migrations, notice: 'Migrate was failed.'
      end
    end

    def rollback
      if Migration.rollback
        redirect_to :migrations, notice: 'Rollback was succeed.'
      else
        redirect_to :migrations, notice: 'Rollback was failed.'
      end
    end

    private
    def migraion_params
      params.require(:ponytail_migration).permit(:name, :raw_content)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ponytail-0.0.2 app/controllers/ponytail/migrations_controller.rb
ponytail-0.0.1 app/controllers/ponytail/migrations_controller.rb