Sha256: daf770344e8ee558c7411a29a0150d939a1873ac15b4a9d60eeddb1d3f3a06bd

Contents?: true

Size: 899 Bytes

Versions: 14

Compression:

Stored size: 899 Bytes

Contents

class Cambium::Admin::UsersController < Cambium::AdminController

  def update
    set_object
    # To make this run smoothly, we remove the password
    # fields from the update_params if they are both
    # missing, that way we don't try to set a blank
    # password.
    p = update_params
    if p[:password].blank? && p[:password_confirmation].blank?
      p = p.except('password','password_confirmation')
    end
    # Now we use the cleansed params `p` and we're ready
    # to try to save the user
    if @object.update(p)
      # If we have successfully saved the user, we're
      # going to sign them back in automatically.
      if @object == current_user
        sign_in(@object, :bypass => true)
      end
      # And then we oome back to regular behavior
      redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} updated!")
    else
      render 'edit'
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cambium-1.3.2 app/controllers/cambium/admin/users_controller.rb
cambium-1.3.1 app/controllers/cambium/admin/users_controller.rb
cambium-1.3.0 app/controllers/cambium/admin/users_controller.rb
cambium-1.2.3 app/controllers/cambium/admin/users_controller.rb
cambium-1.2.2 app/controllers/cambium/admin/users_controller.rb
cambium-1.2.1 app/controllers/cambium/admin/users_controller.rb
cambium-1.2.0 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.6 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.5 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.4 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.3 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.2 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.1 app/controllers/cambium/admin/users_controller.rb
cambium-1.1.0 app/controllers/cambium/admin/users_controller.rb