Sha256: c18744f8bbf8075bcef96d65630dd46e74f0086aa5f1bc6481be9687e5534c04

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

require_dependency "buttafly/application_controller"

module Buttafly
  class LegendsController < ApplicationController

    before_action :set_legend, only: [:show, :edit, :update]

    def new
      @mapping = Buttafly::Mapping.find(params[:mapping_id])
      @legend = @mapping.build_legend
      # binding.pry
      @headers = @mapping.get_origin_headers
      @new_record = @mapping.targetable_model.constantize.new
    end

    def create
      @legend = Buttafly::Legend.new(data: legend_params)
      if @legend.save
        redirect_to contents_path, notice: "legend created"
      else
        redirect_to :back, notice: "not good"
      end
    end

    def show
    end

    def edit
    end

    def index
    end

   private

    def set_legend
      @legend = Buttafly::Legend.find(params[:legend_id])
    end

    def legend_params

      params.require(:legend)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buttafly-0.0.1 app/controllers/buttafly/legends_controller.rb