Mise à jour des attributs des utilisateurs
This commit is contained in:
parent
a42eb7d379
commit
83c0712947
|
@ -38,6 +38,9 @@ class UsersController < ApplicationController
|
|||
def update
|
||||
respond_to do |format|
|
||||
if @user.update(user_params)
|
||||
if @user.unconfirmed? && params.fetch(:user, {}).fetch(:confirm, "0") == "1"
|
||||
@user.confirm!
|
||||
end
|
||||
format.html { redirect_to user_url(@user), notice: "User was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @user }
|
||||
else
|
||||
|
@ -65,6 +68,6 @@ class UsersController < ApplicationController
|
|||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def user_params
|
||||
params.fetch(:user, {})
|
||||
params.require(:user).permit(:name, :email)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,24 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if user.confirmed? %>
|
||||
<div>
|
||||
<%= form.label :email, "Confirmed Email" %>
|
||||
<%= form.text_field :email %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div>
|
||||
<%= form.label :email, "Unconfirmed Email" %>
|
||||
<%= text_field_tag :email, user.confirmable_email, disabled: true %>
|
||||
<br /><%= form.label :confirm, "Confirm?" %>
|
||||
<%= form.check_box :confirm %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue