Class: Gemgento::User::RecurringProfilesController

Inherits:
BaseController show all
Defined in:
app/controllers/gemgento/user/recurring_profiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/gemgento/user/recurring_profiles_controller.rb', line 8

def destroy
  recurring_profile = RecurringProfile.find_by!(id: params[:id], user: current_user)

  respond_to do |format|
    result = recurring_profile.change_state('cancel')

    if result == true
      format.json { render json: { status: true } }
      format.html do
        flash[:notice] = 'The recurring profile has been canceled.'
        redirect_to action: 'index'
      end
    else
      format.json { render json: { errors: result }, status: 422 }
      format.html do
        flash[:warning] = result
        redirect_to action: 'index'
      end
    end
  end
end

#indexObject



4
5
6
# File 'app/controllers/gemgento/user/recurring_profiles_controller.rb', line 4

def index
  @recurring_profile = RecurringProfile.where(user: current_user)
end