46
loading...
This website collects cookies to deliver better user experience
rails new my-project --database=postgresql
source 'https://rubygems.org'
ruby '2.7.1'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 4.1'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 4.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'webdrivers'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
rails new
command. You can see the full list of options by running rails new -h
sudo rm -r my-project
rails new my-project --database=postgresql --skip-keeps --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-active-storage --skip-action-cable --skip-puma --skip-test --skip-bundle --skip-webpack-install
--skip-keeps
why? This avoids adding empty folders to your git repository (I want not commit empty files in my repository)--skip-action-mailer
why? I don’t need this stuff to start with my project--skip-action-mailbox
why? I don’t need this stuff to start with my project--skip-action-text
why? I don’t need this stuff to start with my project--skip-active-storage
why? I don’t need this stuff to start with my project--skip-action-cable
why? I don’t need this stuff to start with my project--skip-puma
why? Puma web server is suitable for Production environment, but for development I can use the default WebBrick web server--skip-test
why? I’m going to use RSpec, so I don’t need the default Minitest stuff--skip-bundle
why? I’m going to make some changes to my Gemfile then I will manually run bundle install
command--skip-webpack-install
why? I’m going to manually run the command rails webpacker:install
after the changes on the Gemfile are donesource 'https://rubygems.org'
ruby '2.7.1'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'pg', '>= 0.18', '< 2.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 4.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
rails new
command options, you can even clean it more by removing unneeded gems manually. Let’s do thatrails
and pg
gems why These two gems are basics to develop the application with Rails and PostgreSQLsass-rails
and webpacker
gems why These two gems are needed to Sprokets (default CSS bundler) and WebPack (default JS bundler)turbolinks
gem why This gem is needed to speed up navigation between pagesbootsnap
gem why This gem is needed to optimization loading of the applicationbyebug
and web-console
gems why These two gems are useful to debugging the applicationspring
, spring-watcher-listen
, and listen
gems why These three gems work together to speed up the development by caching some common operations like running the rails console, tests execution, and so ontznfo-data
why This gem is not necessary on unix-based systems (Mac or Ubuntu), so if you are using Mac or Ubuntu like I, then you can remove itjbuilder
why I’m not going to work with JSON data (at least not for now) which is commonly used in API developmentsource 'https://rubygems.org'
ruby '2.7.1'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'pg', '>= 0.18', '< 2.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 4.0'
gem 'turbolinks', '~> 5'
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
byebug
. Since the default platform on unix-based systems is ruby and I’m not going to developing on Windows, the platform parameter is not necessaryrails new my-light-project --database=postgresql --skip-keeps --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-active-storage --skip-action-cable --skip-puma --skip-test --skip-bundle --skip-webpack-install
-d postgresql
instead of --database=postgresql
-M
instead of --skip-action-mailer
-C
instead of --skip-action-cable
-P
instead of --skip-puma
-T
instead of --skip-test
-B
instead of --skip-bundle
rails new my-light-project -d postgresql --skip-keeps -M --skip-action-mailbox --skip-action-text --skip-active-storage -C -P -T -B --skip-webpack-install
.railsrc
file (You can take a look on mine here).railsrc
file like this--database=postgresql
--skip-keeps
--skip-action-mailer
--skip-action-mailbox
--skip-action-text
--skip-active-storage
--skip-puma
--skip-action-cable
--skip-test
--skip-bundle
--skip-webpack-install
.railsrc
file, you can run only this command to create your rails project rails new my-project
by applying the changes based on the options defined in the .railsrc
file.railsrc
file with the needed optionsrails new my-project
bundle install
rails webpacker:install
rails db:setup
rails s