Class: Chaskiq::SubscribersController
Instance Method Summary
collapse
#authentication_method, #get_referrer
Instance Method Details
#create ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 35
def create
@subscriber = @campaign.list.create_subscriber(resource_params)
if @subscriber.errors.blank?
@subscription = @campaign.subscriptions.find_by(subscriber: @subscriber)
@subscription.subscribe! unless @subscription.subscribed?
flash[:notice] = "you did it!"
redirect_to campaign_path(@campaign)
else
render "new"
end
end
|
#delete ⇒ Object
47
48
49
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 47
def delete
find_subscriber
end
|
#destroy ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 51
def destroy
find_subscriber
begin
if @subscription.unsubscribe!
flash[:notice] = "Thanks, you will not receive more emails from this newsletter!"
redirect_to campaign_path(@campaign)
end
rescue
flash[:notice] = "Thanks, you will not receive more emails from this newsletter!"
redirect_to campaign_path(@campaign)
end
end
|
#edit ⇒ Object
20
21
22
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 20
def edit
find_subscriber
end
|
#new ⇒ Object
16
17
18
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 16
def new
@subscriber = @campaign.subscribers.new
end
|
#show ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 10
def show
find_subscriber
render "edit"
end
|
#update ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/chaskiq/subscribers_controller.rb', line 24
def update
find_subscriber
if @subscriber.update_attributes(resource_params) && @subscriber.errors.blank?
flash[:notice] = "you did it!"
@subscription.subscribe! unless @subscription.subscribed?
redirect_to campaign_path(@campaign)
else
render "edit"
end
end
|