Class: Admin::MappingsController
- Inherits:
-
AdminController
- Object
- ApplicationController
- AdminController
- Admin::MappingsController
- Defined in:
- app/controllers/admin/mappings_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /mappings POST /mappings.json Creates a new mapping.
-
#destroy ⇒ Object
DELETE /mappings/1 DELETE /mappings/1.json Deletes a mapping and redirects to the mappings index.
-
#edit ⇒ Object
GET /mappings/1/edit Prepares a mapping for editing.
-
#index ⇒ Object
GET /import/:id/mappings GET /import/:id/mappings.json Lists all mappings for a specific import.
-
#new ⇒ Object
GET /mappings/new Initializes a new mapping object.
-
#show ⇒ Object
GET /mappings/1 GET /mappings/1.json Shows a specific mapping.
-
#update ⇒ Object
PATCH/PUT /mappings/1 PATCH/PUT /mappings/1.json Updates an existing mapping.
Instance Method Details
#create ⇒ Object
POST /mappings POST /mappings.json Creates a new mapping. If successful, redirects to the mapping’s show page. Otherwise, re-renders the new form.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/admin/mappings_controller.rb', line 43 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 |
#destroy ⇒ Object
DELETE /mappings/1 DELETE /mappings/1.json Deletes a mapping and redirects to the mappings index.
78 79 80 81 82 83 84 |
# File 'app/controllers/admin/mappings_controller.rb', line 78 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 |
#edit ⇒ Object
GET /mappings/1/edit Prepares a mapping for editing.
36 37 |
# File 'app/controllers/admin/mappings_controller.rb', line 36 def edit end |
#index ⇒ Object
GET /import/:id/mappings GET /import/:id/mappings.json Lists all mappings for a specific import. If no mappings exist, it initializes a new one.
14 15 16 17 18 19 |
# File 'app/controllers/admin/mappings_controller.rb', line 14 def index @mappings = Mapping.where(import_id: @import) # Build mappings unless we already have @import.mappings.build if @import.mappings.blank? end |
#new ⇒ Object
GET /mappings/new Initializes a new mapping object.
30 31 32 |
# File 'app/controllers/admin/mappings_controller.rb', line 30 def new @mapping = Mapping.new end |
#show ⇒ Object
GET /mappings/1 GET /mappings/1.json Shows a specific mapping.
24 25 26 |
# File 'app/controllers/admin/mappings_controller.rb', line 24 def show @import = Import.find(params[:import_id]) end |
#update ⇒ Object
PATCH/PUT /mappings/1 PATCH/PUT /mappings/1.json Updates an existing mapping. If successful, redirects to the mappings index. Otherwise, re-renders the edit form.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/admin/mappings_controller.rb', line 63 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 |