[RUBY] [Rails] How to prevent screen transition

Introduction

I will post it for those who have similar troubles because it was difficult to find a way to prevent screen transitions when creating likes and comments functions only with Rails.

version

ruby 2.6.3
Rails 5.2.4.3

Zubari

redirect_to request.referer

Let's put this one line at the end of the controller. That way, the screen will not change even after you press the button!

If you want to know more about redirect_to, I recommend the material here.

Recommended Posts

[Rails] How to prevent screen transition
How to uninstall Rails
How to prevent direct URL typing in Rails
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
[Rails] How to use Scope
How to send value in HTML without screen transition
[Rails] How to use gem "devise"
How to deploy jQuery on Rails
[Rails] How to install Font Awesome
How to transition from the [Swift5] app to the iPhone settings screen
[Rails] How to use devise (Note)
[Rails] How to use flash messages
[rails] How to display db information
[Rails] How to write in Japanese
How to use Ruby on Rails
How to deploy Bootstrap on Rails
Prevent operations! How to securely update Rails manually using transactions
[Rails] How to speed up docker-compose
[Rails] How to add new pages
Rails on Tiles (how to write)
[Rails] How to write exception handling?
[Rails] How to install ImageMagick (RMajick)
[Rails] How to install Font Awesome
[Rails] How to use Active Storage
How to make a splash screen
How to introduce jQuery in Rails 6
[Rails] How to implement star rating
How to return Rails API mode to Rails
How to get along with Rails
[Introduction to Rails] How to use render
How to install Swiper in Rails
How to prevent past dates from being entered in Rails forms
[Rails] How to get the URL of the transition source and redirect
[Rails 6] How to create a dynamic form input screen using cocoon
[Rails 5] How to display the password change screen when using devise
How to prevent duplicate processing by addEventListener
How to implement search functionality in Rails
How to change app name in rails
How to use custom helpers in rails
[Ruby on Rails] How to use CarrierWave
[Rails] How to convert from erb to haml
[Rails] How to upload images using Carrierwave
[Rails] How to use rails console with docker
How to insert a video in Rails