* Enable Rails cops * Fix Rails/DynamicFindBy * Fix Rails/HttpStatus * Fix Rails/Blank * Fix Rails/RequestReferer * Fix Rails/ActiveRecordAliases * Fix Rails/FindBy * Fix Rails/Presence * Fix Rails/Delegate * Fix Rails/Validation * Fix Rails/PluralizationGrammar * Fix Rails/Present * Fix Rails/Output * Fix Rails/Blank * Fix Rails/FilePath * Fix Rails/InverseOf * Fix Rails/LexicallyScopedActionFilter * Add Rails/OutputSafety to TODO * Add Rails/HasManyOrHasOneDependent to TODO * Add Rails/SkipsModelValidations to TODO
57 lines
1.4 KiB
Ruby
57 lines
1.4 KiB
Ruby
module Admin
|
|
class UsersController < Admin::ApplicationController
|
|
def update
|
|
user = User.find(params[:id])
|
|
if user.errors.messages.blank? && user.update(user_params)
|
|
flash[:notice] = "User successfully updated"
|
|
redirect_to "/admin/users/#{params[:id]}"
|
|
else
|
|
render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def user_params
|
|
accessible = %i[
|
|
name
|
|
email
|
|
username
|
|
twitter_username
|
|
github_username
|
|
profile_image
|
|
website_url
|
|
summary
|
|
email_newsletter
|
|
email_comment_notifications
|
|
email_follower_notifications
|
|
organization_id
|
|
org_admin
|
|
bg_color_hex
|
|
text_color_hex
|
|
employer_name
|
|
employer_url
|
|
employment_title
|
|
currently_learning
|
|
available_for
|
|
mostly_work_with
|
|
currently_hacking_on
|
|
location
|
|
email_public
|
|
education
|
|
feed_url
|
|
reputation_modifier
|
|
saw_onboarding
|
|
scholar_email
|
|
facebook_url
|
|
behance_url
|
|
dribbble_url
|
|
medium_url
|
|
gitlab_url
|
|
linkedin_url
|
|
]
|
|
accessible << %i[password password_confirmation] if params[:user][:password].present?
|
|
params.require(:user).permit(accessible)
|
|
end
|
|
end
|
|
end
|