Sha256: 139118d2302b6da999c01558837b024dd153af5090f2f740129a6caf030887c1
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Feste class SubscriptionsController < ActionController::Base include Feste::Authenticatable protect_from_forgery with: :exception layout "feste/application" def index @subscriber = subscriber end def update if update_subscriptions flash[:success] = "You have successfully updated your subscriptions!" else flash[:notice] = "Something went wrong! Please try again later." end redirect_back( fallback_location: subscriptions_path(token: params[:token]) ) end private def user_params params.require(subscriber.class.to_s.downcase.to_sym). permit(subscriptions: []) end def subscriptions_params user_params[:subscriptions] end def update_subscriptions subscribed = subscriber.subscriptions.where(id: subscriptions_params) unsubscribed = subscriber.subscriptions.where. not(id: subscriptions_params) subscribed.update_all(canceled: false) && unsubscribed.update_all(canceled: true) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
feste-0.2.1 | app/controllers/feste/subscriptions_controller.rb |