Module: Hyrax::UsersControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- UsersController
- Defined in:
- app/controllers/concerns/hyrax/users_controller_behavior.rb
Instance Method Summary collapse
-
#edit ⇒ Object
Display form for users to edit their profile information.
- #index ⇒ Object
- #notifications_number ⇒ Object
-
#show ⇒ Object
Display user profile.
-
#update ⇒ Object
Process changes from profile form.
- #update_directory? ⇒ Boolean
Instance Method Details
#edit ⇒ Object
Display form for users to edit their profile information
25 26 27 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 25 def edit @trophies = Hyrax::TrophyPresenter.find_by_user(@user) end |
#index ⇒ Object
15 16 17 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 15 def index @users = search(params[:uq]) end |
#notifications_number ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 53 def notifications_number @notify_number = 0 return if action_name == "index" && controller_name == "mailbox" return unless user_signed_in? @notify_number = current_user.mailbox.inbox(unread: true).count end |
#show ⇒ Object
Display user profile
20 21 22 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 20 def show @presenter = Hyrax::UserProfilePresenter.new(@user, current_ability) end |
#update ⇒ Object
Process changes from profile form
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 30 def update if params[:user] @user.attributes = user_params @user.populate_attributes if update_directory? end unless @user.save redirect_to hyrax.edit_profile_path(@user.to_param), alert: @user.errors. return end # TODO: this should be moved to TrophiesController params.keys.select { |k, _v| k.starts_with? 'remove_trophy_' }.each do |smash_trophy| smash_trophy = smash_trophy.sub(/^remove_trophy_/, '') current_user.trophies.where(work_id: smash_trophy).destroy_all end UserEditProfileEventJob.perform_later(@user) redirect_to hyrax.profile_path(@user.to_param), notice: "Your profile has been updated" end |
#update_directory? ⇒ Boolean
49 50 51 |
# File 'app/controllers/concerns/hyrax/users_controller_behavior.rb', line 49 def update_directory? ['1', 'true'].include? params[:user][:update_directory] end |