Sha256: fca66abf3953718c0b14a5d9d7a3bca66eda7e90a9ff2d087c55a9a100b112fb

Contents?: true

Size: 1.42 KB

Versions: 125

Compression:

Stored size: 1.42 KB

Contents

class SettingsController < ApplicationController
    
  before_filter :authenticate_user!
  
  def index
  end

  def update_all
    success = false

    #If no section selected, skips and gives error
    if params[:settings_section].present?
      section = params[:settings_section].to_s

      #Updating notifications settings
      if section.eql? "notifications"
        #Notify by email setting
        if params[:notify_by_email].present?
          notify_by_email = params[:notify_by_email].to_s
          current_subject.notify_by_email = false if notify_by_email.eql? "never"
          current_subject.notify_by_email = true if notify_by_email.eql? "always"
        end
      end

      #Updating language
      if section.eql? "language"
        #Preferred language setting
        if params[:language].present?
          lang = params[:language].to_s
          if lang == 'browser'
            current_user.language = nil
          else
            current_user.language = lang[0..1]
          end
        end
      end

      #Here sections to add
      #if section.eql? "section_name"
      #   blah blah blah
      #end

      # Was everything ok?
      success = current_subject.save && current_user.save
    end

    #Flashing and redirecting
    if success
      flash[:success] = t('settings.success')
    else
      flash[:error] = t('settings.error')
    end
    # render :action => :index

    redirect_to settings_path
  end

end

Version data entries

125 entries across 125 versions & 2 rubygems

Version Path
social_stream-2.1.1 base/app/controllers/settings_controller.rb
social_stream-1.1.12 base/app/controllers/settings_controller.rb
social_stream-base-1.1.11 app/controllers/settings_controller.rb
social_stream-2.1.0 base/app/controllers/settings_controller.rb
social_stream-base-2.1.0 app/controllers/settings_controller.rb
social_stream-2.0.4 base/app/controllers/settings_controller.rb
social_stream-base-2.0.4 app/controllers/settings_controller.rb
social_stream-2.0.3 base/app/controllers/settings_controller.rb
social_stream-base-2.0.3 app/controllers/settings_controller.rb
social_stream-1.1.11 base/app/controllers/settings_controller.rb
social_stream-base-1.1.10 app/controllers/settings_controller.rb
social_stream-1.1.10 base/app/controllers/settings_controller.rb
social_stream-base-1.1.9 app/controllers/settings_controller.rb
social_stream-1.1.9 base/app/controllers/settings_controller.rb
social_stream-base-1.1.8 app/controllers/settings_controller.rb
social_stream-1.1.8 base/app/controllers/settings_controller.rb
social_stream-base-1.1.7 app/controllers/settings_controller.rb
social_stream-2.0.2 base/app/controllers/settings_controller.rb
social_stream-base-2.0.2 app/controllers/settings_controller.rb
social_stream-2.0.1 base/app/controllers/settings_controller.rb