[Rails] I want to display the link destination of link_to in a separate tab

When using link_to in Rails, I wanted to display it in a separate tab, so I implemented it, so I will leave it as a memo.

procedure

First, specify the character string to be displayed and the link destination URL with link_to.

<%= link_to "String", "Link URL" %>

Added target:: _ blank to display in a separate tab

<%= link_to "String", "Link URL", target: :_blank %>

Now you can open it in another tab. However, this has problems in terms of performance and security. .. ..

-Google engineer warns, "Open in another tab" link is actually dangerous! ?? [Summary of SEO information] -Is it really dangerous? Dangerous "Open in another tab (target =" _ blank ")"

To avoid this problem, add rel =" noopener noreferrer ".

<%= link_to "String", "Link URL", target: :_blank, rel: "noopener noreferrer" %>

Now you can open another tab with confidence.

Recommended Posts

[Rails] I want to display the link destination of link_to in a separate tab
[Rails] I want to send data of different models in a form
I want to use a little icon in Rails
I want to display the name of the poster of the comment
I want to define a function in Rails Console
I want to create a form to select the [Rails] category
I want to control the display of the upper management navigation bar (Control menu) in Liferay 7 / DXP
[Rails] How to omit the display of the character string of the link_to method
I want to change the value of Attribute in Selenium of Ruby
[Ruby] I want to display posted items in order of newest date
I want to display an error message when registering in the database
Change the save destination of the image to S3 in the Rails app. Part 2
I tried to organize the session in Rails
I want to var_dump the contents of the intent
I want to get the value in Ruby
[Ruby on Rails] How to make the link destination part of the specified id
Rails6 I want to make an array of values with a check box
I want to import the pull-down menu items when submitting a form in Rails into CSV and display them from the DB data.
How to make a unique combination of data in the rails intermediate table
I want to recursively get the superclass and interface of a certain class
How to set the display time to Japan time in Rails
I want to call a method of another class
I want to embed any TraceId in the log
I want to know the answer of the rock-paper-scissors app
I summarized the display format of the JSON response of Rails
I want to click a GoogleMap pin in RSpec
I want to return the scroll position of UITableView!
[Rails] How to display an image in the view
I want to add a delete function to the comment function
For those who want to use MySQL for the database in the environment construction of Rails6 ~.
[Active Admin] I want to specify the scope of the collection to be displayed in select_box
[Rails] How to display the weather forecast of the registered address in Japanese using OpenWeatherMap
Even if I want to convert the contents of a data object to JSON in Java, there is a circular reference ...
I want to find the MD5 checksum of a file in Java and get the result as a string in hexadecimal notation.
I want to find a relative path in a situation using Path
[Rails] [bootstrap] I want to change the font size responsively
I want to make a specific model of ActiveRecord ReadOnly
I want to change the log output settings of UtilLoggingJdbcLogger
I want to call a method and count the number
How to display a graph in Ruby on Rails (LazyHighChart)
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I want to give a class name to the select attribute
I want to create a Parquet file even in Ruby
[Rails] How to display the list of posts by category
I tried to make a client of RESAS-API in Java
[Rails] Where to be careful in the description of validation
I want to transition to the same screen in the saved state
I want to use FireBase to display a timeline like Twitter
[Ruby] I want to reverse the order of the hash table
[Rails] How to display information stored in the database in view
I want to simplify the conditional if-else statement in Java
After posting an article with Rails Simple Calendar, I want to reflect it in the calendar.
I want to get a list of the contents of a zip file and its uncompressed size
I want to change the color of the upper control navigation bar (Control menu) in Liferay 7 / DXP
Implemented a strong API for "I want to display ~~ on the screen" with simple CQRS
I tried to make a message function of Rails Tutorial extension (Part 2): Create a screen to display
I want to recreate the contents of assets from scratch in the environment built with capistrano
I tried using Docker because I don't want to pollute the local environment in Microsoft Teams tab development of MS Learn
[Swift] When you want to know if the number of characters in a String matches a certain number ...
I tried to implement Ajax processing of like function in Rails
I want to make a button with a line break with link_to [Note]