As a memorandum, I will summarize the options that I personally feel "don't use often when doing rails new
"and the settings that are often made when creating a new project.
First of all, about the options that are often added when doing rails new
.
Each option will be described later.
rails _6.0.3.2_ new appname --database=mysql --skip-test
rails _6.0.3.2_ new
This will allow you to specify the version of rails.
Please change the value of _6.0.3.2_
each time.
--database=mysql
If you don't specify a DB like this, the default DB will be sqlite
.
This time it is a setting to use mysql
.
--skip-test
When you generate a project by default, a Minitest is created. I myself often use RSpec for testing, so I try not to generate a Minitest as described above.
From here, it will be the setting after actually doing rails new
.
rails g
commandconfig/application.rb
module appname
class Application < Rails::Application
#Add the following
config.generators do |g|
g.stylesheets false
g.javascripts false
g.helper false
g.test_framework false
end
config.time_zone = "Tokyo"
config.i18n.default_locale = :ja
end
end
The following parts were mainly added this time.
config.generators do |g|
g.stylesheets false
g.javascripts false
g.helper false
g.test_framework false
end
If you create a controller with the rails g
command, the file will be generated automatically, but this description is to prevent unnecessary things (coffee and css) from being generated.
The rails g
command is something you use a lot during the development process, so it's a lot easier to do this first.
config.time_zone = "Tokyo"
config.i18n.default_locale = :ja
Also, here we will set the default language to Japanese and the time zone default to Tokyo.
config.i18n.default_locale = :ja
However, there is a caution about the above (Japanese localization), and an error may occur when accessing ʻusers / sign_up` when using the devise Gem. So, if you think "Is it okay to translate it into Japanese now? I'm tired of getting an error", I think that you don't have to make any special settings here.
Recommended Posts