Class: Admin::MappingsController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/mappings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /mappings POST /mappings.json



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/admin/mappings_controller.rb', line 35

def create
  @mapping = Mapping.new(mapping_params)

  respond_to do |format|
    if @mapping.save
      format.html do
        redirect_to admin_import_mapping_path(@import, @mapping), notice: "Mapping was successfully created."
      end
      format.json { render :show, status: :created, location: @mapping }
    else
      format.html { render :new }
      format.json { render json: @mapping.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /mappings/1 DELETE /mappings/1.json



67
68
69
70
71
72
73
# File 'app/controllers/admin/mappings_controller.rb', line 67

def destroy
  @mapping.destroy
  respond_to do |format|
    format.html { redirect_to admin_import_mappings_url(@import), notice: "Mapping was successfully destroyed." }
    format.json { head :no_content }
  end
end

#editObject

GET /mappings/1/edit



30
31
# File 'app/controllers/admin/mappings_controller.rb', line 30

def edit
end

#indexObject

GET /import/:id/mappings GET /import/:id/mappings.json



11
12
13
14
15
16
# File 'app/controllers/admin/mappings_controller.rb', line 11

def index
  @mappings = Mapping.where(import_id: @import)

  # Build mappings unless we already have
  @import.mappings.build if @import.mappings.blank?
end

#newObject

GET /mappings/new



25
26
27
# File 'app/controllers/admin/mappings_controller.rb', line 25

def new
  @mapping = Mapping.new
end

#showObject

GET /mappings/1 GET /mappings/1.json



20
21
22
# File 'app/controllers/admin/mappings_controller.rb', line 20

def show
  @import = Import.find(params[:import_id])
end

#updateObject

PATCH/PUT /mappings/1 PATCH/PUT /mappings/1.json



53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/admin/mappings_controller.rb', line 53

def update
  respond_to do |format|
    if @mapping.update(mapping_params)
      format.html { redirect_to admin_import_mappings_path(@mapping.import), notice: "Mapping was successfully updated." }
      format.json { render :show, status: :ok, location: @mapping }
    else
      format.html { render :edit }
      format.json { render json: @mapping.errors, status: :unprocessable_entity }
    end
  end
end