Sha256: 1145ba962f64694d4a700684c8e6ebe2464d73983db3eb1539403739795d0bfb

Contents?: true

Size: 856 Bytes

Versions: 7

Compression:

Stored size: 856 Bytes

Contents

module DiscoApp::Admin::Concerns::SourcesController

  extend ActiveSupport::Concern

  included do
    before_action :find_source, only: [:edit, :update, :destroy]
  end

  def index
    @sources = DiscoApp::Source.all
  end

  def new
    @source = DiscoApp::Source.new
  end

  def create
    @source = DiscoApp::Source.new(source_params)
    if @source.save
      redirect_to admin_sources_path
    else
      render 'new'
    end
  end

  def edit
  end

  def update
    if @source.update(source_params)
      redirect_to edit_admin_plan_path(@source)
    else
      render 'edit'
    end
  end

  def destroy
    source.destroy
    redirect_to admin_sources_path
  end

  private

    def find_source
      @source = DiscoApp::Source.find(params[:id])
    end

    def source_params
      params.require(:source).permit(:source, :name)
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.0 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.2 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.3 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.6 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.4 app/controllers/disco_app/admin/concerns/sources_controller.rb
disco_app-0.18.1 app/controllers/disco_app/admin/concerns/sources_controller.rb