Sha256: 698f4bba376886e5d6eaeb2addf898a9313b744e7f0a03f166e93dfb91df4d5f

Contents?: true

Size: 843 Bytes

Versions: 11

Compression:

Stored size: 843 Bytes

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 = UserPreferencesForm.new(
        user:         thredded_current_user,
        messageboard: messageboard_or_nil,
        params:       params.fetch(:user_preferences_form, {}).permit(
          :notify_on_mention,
          :notify_on_message,
          :messageboard_notify_on_mention,
        )
      )
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
thredded-0.7.0 app/controllers/thredded/preferences_controller.rb
thredded-0.6.3 app/controllers/thredded/preferences_controller.rb
thredded-0.6.2 app/controllers/thredded/preferences_controller.rb
thredded-0.6.1 app/controllers/thredded/preferences_controller.rb
thredded-0.6.0 app/controllers/thredded/preferences_controller.rb
thredded-0.5.1 app/controllers/thredded/preferences_controller.rb
thredded-0.5.0 app/controllers/thredded/preferences_controller.rb
thredded-0.4.0 app/controllers/thredded/preferences_controller.rb
thredded-0.3.2 app/controllers/thredded/preferences_controller.rb
thredded-0.3.1 app/controllers/thredded/preferences_controller.rb
thredded-0.3.0 app/controllers/thredded/preferences_controller.rb