Class: Doubleoptin::SubscribersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Doubleoptin::SubscribersController
- Defined in:
- app/controllers/doubleoptin/subscribers_controller.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#confirm ⇒ Object
POST /confirm?key=1 (not REST).
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#unsubscribe ⇒ Object
POST /unsubscribe?key=1 (not REST).
- #update ⇒ Object
Instance Method Details
#authenticate ⇒ Object
78 79 80 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 78 def authenticate super end |
#confirm ⇒ Object
POST /confirm?key=1 (not REST)
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 26 def confirm @subscriber = Doubleoptin::Subscriber.find_by_nonce :confirm, params[:key] respond_to do |format| if !@subscriber.unsubscribed && @subscriber.try(:update_attribute, :confirmed, true) format.html else format.html { redirect_to :root } end end end |
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 12 def create @subscriber = Doubleoptin::Subscriber.new params.require(:subscriber).permit(:name, :email) respond_to do |format| if @subscriber.save SubscriptionMailer.confirm(@subscriber).deliver_now format.html else format.html { redirect_to subscription_path } end end end |
#destroy ⇒ Object
70 71 72 73 74 75 76 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 70 def destroy @subscriber.destroy respond_to do |format| format.html { redirect_to subscribers_url, notice: 'Subscriber was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
55 56 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 55 def edit end |
#index ⇒ Object
51 52 53 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 51 def index @subscribers = Subscriber.all end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 8 def new @subscriber = Doubleoptin::Subscriber.new end |
#unsubscribe ⇒ Object
POST /unsubscribe?key=1 (not REST)
39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 39 def unsubscribe @subscriber = Doubleoptin::Subscriber.find_by_nonce :unsubscribe, params[:key] respond_to do |format| if @subscriber.try :update_attribute, :unsubscribed, true format.html else format.html { redirect_to :root } end end end |
#update ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/doubleoptin/subscribers_controller.rb', line 58 def update respond_to do |format| if @subscriber.update params.require(:subscriber).permit(:name, :email, :unsubscribed, :confirmed) format.html { redirect_to subscribers_url, notice: 'Subscriber was successfully updated.' } format.json { render :index, status: :ok } else format.html { render :edit } format.json { render json: @subscriber.errors, status: :unprocessable_entity } end end end |