This is a post for the output of "Ruby on Rails 5 Quick Learning Practice Guide". Since I use rails for business, I am trying to accumulate knowledge even in private. This time, I will post the settings related after launching the application of this book.
Added the following to the last line of Gemfiile
gem 'slim-rails'
gem 'html2slim'
After writing, execute the following in the terminal
bundle install
bundle exec erb2slim app/views/layouts/ -d
The command on the second line creates a slim file based on erb from the files under "app/views/layouts /". The option "-d" is an option to delete the html file. If you want to keep the html file, do not add this option.
Added the following to the last line of Gemfiile
gem 'bootstrap'
After writing, execute the following in the terminal
bundle install
Delete app/assets/stylesheets/application.css, create application.scss in the same folder, and add the following description to the file.
app/assets/stylesheets/application.scss
@import 'bootstrap'
There is a translation in the rails-I18n repository on GitHub, so download it with the following command.
wget https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/fa.yml -P config/locales/
After downloading, create locale.rb so that Japanese content is used by default, and add the following description.
config/initializers/locale.rb
Rails.application.config.i18n.default_locale = :ja
When the model name is displayed on the screen, the column name of the table is output as it is. (Example: When it is User.name, it will be displayed as name) Therefore, assign Japanese corresponding to the model name and column name to ja.yml. Please note that if the indentation shifts, it will not work!
config/locales/ja.yml
---
ja:
activerecord:
errors:
messages:
record_invalid: 'Validation failed: %{errors}'
restrict_dependent_destroy:
has_one: "%{record}Cannot be deleted because it exists"
has_many: "%{record}Cannot be deleted because it exists"
models:
task:task
attributes:
task:
id: ID
name:name
description:detailed explanation
created_at:Registered Date
updated_at:Update date and time
After definition, use the human_attribute_name method in the view to display in Japanese.
Task.human_attribute_name(:name)
In this description, it is displayed as "Name".
-Ruby on Rails 5 Quick Learning Practice Guide that can be used in the field