Class: Proclaim::SubscriptionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/proclaim/subscriptions_controller.rb', line 23

def create
	@subscription = Subscription.new(subscription_params)

	authorize @subscription

	if antispam_params[:answer] == antispam_params[:solution]
		respond_to do |format|
			if @subscription.save
				format.html { redirect_to subscribed_path }
			else
				format.html { render :new }
			end
		end
	else
		@subscription.errors.add(:base, "Antispam question wasn't answered correctly")
		respond_to do |format|
			format.html { render :new }
		end
	end
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/proclaim/subscriptions_controller.rb', line 44

def destroy
	authorize @subscription

	@subscription.destroy
	redirect_to unsubscribed_path, notice: "Successfully unsubscribed."
end

#newObject



8
9
10
11
# File 'app/controllers/proclaim/subscriptions_controller.rb', line 8

def new
	@subscription = Subscription.new
	authorize @subscription
end

#subscribedObject



13
14
# File 'app/controllers/proclaim/subscriptions_controller.rb', line 13

def subscribed
end

#unsubscribeObject



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

def unsubscribe
	authorize @subscription
end

#unsubscribedObject



20
21
# File 'app/controllers/proclaim/subscriptions_controller.rb', line 20

def unsubscribed
end