Sha256: abd3be176b7188554c9530e12029d1dfced3b64d1100d8e27ba6878721514a23
Contents?: true
Size: 890 Bytes
Versions: 1
Compression:
Stored size: 890 Bytes
Contents
module Catarse class UnsubscribesController < BaseController inherit_resources belongs_to :user def create params[:user][:unsubscribes_attributes].each_value do |u| u[:notification_type_id] = NotificationType.where(name: 'updates').last.id if u[:project_id].nil? #unsubscribe from all projects if u[:subscribed] == '1' && !u[:id].nil? #change from unsubscribed to subscribed parent.unsubscribes.where(project_id: u[:project_id], notification_type_id: u[:notification_type_id]).destroy_all elsif u[:subscribed] == '0' && u[:id].nil? #change from subscribed to unsubscribed parent.unsubscribes.create!(project_id: u[:project_id], notification_type_id: u[:notification_type_id]) end end flash[:notice] = t('catarse.users.current_user_fields.updated') return redirect_to user_path(parent, :anchor => 'unsubscribes') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
catarse_core-1.0.0.beta | app/controllers/catarse/unsubscribes_controller.rb |