The carrier service : remove_avatar
check box is getting an incredible amount of work to me Develop Profile Change Form I am following CareerWave Documentation.
I placed the uploader on the user model. I have added : avatar
and : remove_avatar
in ApplicationController sanitizer
application_controller.rb
def configured.permended_permatates devise_parameter_sanitizer.for (: account_update) do | U | U.permit (: first_name ,: last_name ,: email, password: password_confirmation, avatar, remove_avatar) end devise_parameter_sanitizer.for (: sign_up) do | U | U.permit (: first_name ,: last_name,: email, password: password_uponation) ending
I've added to edit : remove_avatar
/devise/registrations/edit.html. ARB
& lt;% = form_for (resource, as: source_name, url: registration_path (Resource_name), html: {method :: put, multipart: true}) Do F | | & Gt%; & Lt;% = f.label: Avatar% & gt; & Lt; Br / & gt; & Lt;% = image_tag (source.avatar_url (thumb))% & gt; & Lt;% = f.file_field: Avatar, Accept: 'Image / JPEG, Image / PNG'% & gt; & Lt; Label & gt; & Lt;% = f.check_box: remove_avatar% & gt; Remove avatar & lt; / Label & gt; & Lt;% = f.label: first_name% & gt; & Lt; Br / & gt; & Lt;% = f.text_field: first_name, autofocus: true% & gt; & Lt;% = f.label: last_name% & gt; & Lt; Br / & gt; & Lt;% = f.text_field: last_name% & gt; & Lt;% = f.label: email% & gt; & Lt; Br / & gt; & Lt;% = f.email_field: email% & gt; & Lt; Div & gt; & Lt;% = link_to 'Cancel', Resource% & gt; & Lt;% = f.submit "Update"% & gt; & Lt; / Div & gt; & Lt;% end% & gt;
In addition to removing the avatars, there is no other problem with the carrier when I check the box and submit the form, the picture is not deleted.
I did a test, where I used instead of the registration controller for the user's controller and instead of form @user
resource
And I was able to work it, I want to stay on the Convention and use the Registration Controller. What am I doing or what's wrong?
@ user Revove_River! @ User.remove_avatar = true @ user.save @ user.reload
Try it out, you can help.
No comments:
Post a Comment