Sha256: e6b570555b1c37b3b6fd77b146c6b5c82a5a47633685ed65be8884f8446e4574

Contents?: true

Size: 1.77 KB

Versions: 57

Compression:

Stored size: 1.77 KB

Contents

module Account::Users::ControllerBase
  extend ActiveSupport::Concern

  included do
    load_and_authorize_resource :user, class: "User", prepend: true,
      member_actions: (defined?(MEMBER_ACTIONS) ? MEMBER_ACTIONS : []),
      collection_actions: (defined?(COLLECTION_ACTIONS) ? COLLECTION_ACTIONS : [])

    before_action do
      # for magic locales.
      @child_object = @user
    end

    private

    include strong_parameters_from_api
  end

  # GET /account/users/1/edit
  def edit
  end

  # GET /account/users/1
  def show
  end

  def updating_password?
    params[:user].key?(:password)
  end

  # PATCH/PUT /account/users/1
  # PATCH/PUT /account/users/1.json
  def update
    respond_to do |format|
      if updating_password? ? @user.update_with_password(user_params) : @user.update_without_password(user_params)
        # if you update your own user account, devise will normally kick you out, so we do this instead.
        bypass_sign_in current_user.reload
        format.html { redirect_to [:edit, :account, @user], notice: t("users.notifications.updated") }
        format.json { render :show, status: :ok, location: [:account, @user] }
      else
        format.html { render :edit, status: :unprocessable_entity }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  private

  def permitted_fields
    raise "It looks like you've removed `permitted_fields` from your controller. This will break Super Scaffolding."
  end

  def permitted_arrays
    raise "It looks like you've removed `permitted_arrays` from your controller. This will break Super Scaffolding."
  end

  def process_params(strong_params)
    raise "It looks like you've removed `process_params` from your controller. This will break Super Scaffolding."
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
bullet_train-1.4.2 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.4.1 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.4.0 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.25 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.24 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.23 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.22 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.21 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.20 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.19 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.18 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.17 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.16 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.15 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.14 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.13 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.12 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.11 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.10 app/controllers/concerns/account/users/controller_base.rb
bullet_train-1.3.9 app/controllers/concerns/account/users/controller_base.rb