A method used to represent the time and date. It can correspond to the specified local time. It is used when "posted at what time on what day of the month" on SNS. It is used when you want to display the created_at column of the table.
config/application.rb
class Application < Rails::Application
config.i18n.default_locale = :ja #in Japan's case
config.time_zone = 'Tokyo' #In the case of Tokyo
end
Make the above description in all Rails environment settings files.
Create a ja.yml file.
config/locales/ja.yml
ja:
time:
formats:
default: "%Y/%m/%d %H:%M:%S"
After making the above two settings, just put "l" before the method to display the column with the time. ex) If the extension is .html.erb
<%= l name.created_at %> #2020/9/27/ 23:32:09 is displayed
It seems to be an indispensable method when implementing the posting function.