Class: SubscriptionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/subscriptions_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject


20
21
22
23
24
# File 'app/controllers/subscriptions_controller.rb', line 20

def destroy
  @subscription = current_user.subscriptions.find(params[:id])
  @subscription.destroy!
  redirect_to_back_or_default project_path(@subscription.project.to_param)
end

#indexObject


4
5
6
7
# File 'app/controllers/subscriptions_controller.rb', line 4

def index
  @subscriptions = current_user.subscriptions.includes(:project).order('projects.latest_release_published_at DESC').paginate(page: params[:page])
  @projects = current_user.recommended_projects.limit(5)
end

#subscribeObject


15
16
17
18
# File 'app/controllers/subscriptions_controller.rb', line 15

def subscribe
  @subscription = current_user.subscriptions.create(project_id: params[:project_id])
  redirect_to_back_or_default project_path(@subscription.project.to_param)
end

#updateObject


9
10
11
12
13
# File 'app/controllers/subscriptions_controller.rb', line 9

def update
  @subscription = current_user.subscriptions.find(params[:id])
  @subscription.update_attributes(subscription_params)
  redirect_to_back_or_default project_path(@subscription.project.to_param)
end