cirandas.net

ref: master

plugins/delivery/controllers/myprofile/delivery_plugin/admin_method_controller.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require_dependency 'delivery_plugin/display_helper'

class DeliveryPlugin::AdminMethodController < MyProfileController

  protect 'edit_profile', :profile

  helper DeliveryPlugin::FieldHelper
  helper DeliveryPlugin::DisplayHelper

  def new
    @delivery_method = profile.delivery_methods.build
    self.edit
  end

  def edit
    @delivery_method ||= profile.delivery_methods.find_by id: params[:id]
    if params[:delivery_method].present? and @delivery_method.update params[:delivery_method]
      render partial: 'list'
    else
      render partial: 'edit', locals: {delivery_method: @delivery_method}
    end
  end

  def destroy
    @delivery_method = profile.delivery_methods.find params[:id]
    @delivery_method.destroy
    render nothing: true
  end

  protected

end