Incident (rails) that is logged out when user editing of the application

Case details

An esoteric incident in Ruby onrails6

User features created with devise I made a function to edit passwords and email addresses When I update my edits, I get logged out.

Solution

It seems that it was properly listed in the rails guidebook! It seems that if you edit the password or email address by default, you will be logged out.

How to solve this? .. .. ..

user.controller.rb



 def edit
    @user=User.find(params[:id])
  end

  def update
     @user = User.find(params[:id])
     if @user.update(user_params)
      bypass_sign_in(@user)       #Describe this! !! !! !! !! !! !! !!

      else
        render 'edit'
      end

  end

By adding the code described in the comment out I succeeded in resolving this case. : sunny:

Wow Wow: shamrock:

Recommended Posts

Incident (rails) that is logged out when user editing of the application
[Rails] When the layout change of devise is not reflected
About the solution to the problem that the log of logback is not output when the web application is stopped
[Rails] How to temporarily save the request URL of a user who is not logged in and return to that URL after logging in
[Rails] How to solve the problem that the default image is overwritten when editing without uploading the image [Active Storage]
Cloud9 is out of memory: Rails tutorial memorandum
Upcast (Java) that can reduce the amount of change when the specification is changed
I want to get the information of the class that inherits the UserDetails class of the user who is logged in with Spring Boot.
[Ruby on Rails] Implementation of validation that works only when the conditions are met
When I created a user my page, the user editing function of devise became strange.
When the hover of Eclipse is hard to see
When the month of the date is acquired, the January shift
Roughly the flow of web application development with Rails.
I can't get out of the Rails dbconsole screen
Fixed the phenomenon that vuetify built in Rails is not loaded when page transition is done
Review the basic knowledge of ruby that is often forgotten
Determine that the value is a multiple of 〇 in Ruby
[Docker] List of errors that occurred when building the environment
The idea of cutting off when the error is not resolved
(Ruby on Rails6) Display of the database that got the id of the database
% rails db: When creating, the LoadError caused by mimemagic is
[Swift] Get the timing when the value of textField is changed
Logback log is not output when the server application is closed
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
Is it easy for the user to use when implementing general-purpose functions? Let's be aware of
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
A memo that containerizes the simple chat application of Node.js + socket.io
Problem that the attribute of User model becomes nil in ActionMailer
Let's make a custom_cop that points out the shaking of the name
Investigation method when the CPU of the server running java is heavy
How to write the view when Vue is introduced in Rails?
Summary: Implementation of a function that switches the logical value when a link is clicked [for own output]
Summary of tips (Rails) that you can use all the way because you understand that it is jQuery discount