Sha256: 34dde5f5d54b50e8a408487059b56a4496c03e5656b5ca9384d36ef9c364a456

Contents?: true

Size: 1.27 KB

Versions: 38

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Thredded
  class PreferencesController < Thredded::ApplicationController
    before_action :thredded_require_login!,
                  :init_preferences

    def edit; end

    def update
      if @preferences.save
        flash[:notice] = t('thredded.preferences.updated_notice')
        redirect_back fallback_location: edit_preferences_url(@preferences.messageboard)
      else
        render :edit
      end
    end

    private

    def init_preferences
      @preferences = Thredded::UserPreferencesForm.new(
        user:         thredded_current_user,
        messageboard: messageboard_or_nil,
        messageboards: policy_scope(Thredded::Messageboard.all),
        params: preferences_params
      )
    end

    def preferences_params
      params.fetch(:user_preferences_form, {}).permit(
        :auto_follow_topics,
        :messageboard_auto_follow_topics,
        :follow_topics_on_mention,
        :messageboard_follow_topics_on_mention,
        messageboard_notifications_for_followed_topics_attributes: %i[notifier_key id messageboard_id enabled],
        notifications_for_followed_topics_attributes: %i[notifier_key id enabled],
        notifications_for_private_topics_attributes: %i[notifier_key id enabled]
      )
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
thredded-1.1.0 app/controllers/thredded/preferences_controller.rb
thredded-1.0.1 app/controllers/thredded/preferences_controller.rb
thredded-1.0.0 app/controllers/thredded/preferences_controller.rb
thredded-0.16.16 app/controllers/thredded/preferences_controller.rb
thredded-0.16.15 app/controllers/thredded/preferences_controller.rb
thredded-0.16.14 app/controllers/thredded/preferences_controller.rb
thredded-0.16.13 app/controllers/thredded/preferences_controller.rb
thredded-0.16.12 app/controllers/thredded/preferences_controller.rb
thredded-0.16.11 app/controllers/thredded/preferences_controller.rb
thredded-0.16.10 app/controllers/thredded/preferences_controller.rb
thredded-0.16.9 app/controllers/thredded/preferences_controller.rb
thredded-0.16.8 app/controllers/thredded/preferences_controller.rb
thredded-0.16.7 app/controllers/thredded/preferences_controller.rb
thredded-0.16.6 app/controllers/thredded/preferences_controller.rb
thredded-0.16.5 app/controllers/thredded/preferences_controller.rb
thredded-0.16.4 app/controllers/thredded/preferences_controller.rb
thredded-0.16.3 app/controllers/thredded/preferences_controller.rb
thredded-0.16.1 app/controllers/thredded/preferences_controller.rb
thredded-0.16.0 app/controllers/thredded/preferences_controller.rb
thredded-0.15.5 app/controllers/thredded/preferences_controller.rb