とりあえず、Rails 5.2.3 環境を作って動作確認まで。
Rails 5.2.3 環境のインストールと動作確認
gem の設定
bundle で gem をインストールする際に、ドキュメントをインストールすると遅くなったり容量を喰ったりであまりよろしくないので、bundle install の際にドキュメントをインストールしないように設定
$HOME/.gemrc
1 2 |
install: --no-document update: --no-document |
アプリディレクトリの作成と bundler 初期化
アプリディレクトリを作って bundle 初期化
1 2 3 4 |
$ mkdir devise_sample $ cd devise_sample $ bundle init Writing new Gemfile to /home/rails/devise_sample/Gemfile |
Gemfile を編集する
Gemfile の rails のコメントアウトを外して、5.2.3 を使うように設定
1 2 3 4 5 6 7 |
# frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } gem "rails", '~> 5.2.3' |
gem のインストールを実施
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ bundle install --path vendor/bundle Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Fetching rake 12.3.3 Installing rake 12.3.3 Fetching builder 3.2.3 Fetching mini_portile2 2.4.0 Fetching crass 1.0.4 Fetching rack 2.0.7 : : Installing rails 5.2.3 Bundle complete! 1 Gemfile dependency, 41 gems now installed. Bundled gems are installed into `./vendor/bundle` Post-install message from i18n: HEADS UP! i18n 1.1 changed fallbacks to exclude default locale. But that may break your application. Please check your Rails app for 'config.i18n.fallbacks = true'. If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be 'config.i18n.fallbacks = [I18n.default_locale]'. If not, fallbacks will be broken in your app by I18n 1.1.x. For more info see: https://github.com/svenfuchs/i18n/releases/tag/v1.1.0 |
Rails アプリの初期化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$ bundle exec rails new . --skip-bundle exist create README.md create Rakefile create .ruby-version create config.ru create .gitignore conflict Gemfile Overwrite /home/n22509/Rails/devise_sample/Gemfile? (enter "h" for help) [Ynaqdhm] y force Gemfile run git init from "." Initialized empty Git repository in /home/n22509/Rails/devise_sample/.git/ create package.json create app create app/assets/config/manifest.js : : create test/system create test/system/.keep create test/application_system_test_case.rb create storage create storage/.keep create tmp/storage create tmp/storage/.keep remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_5_2.rb |
必要な Gem のインストール
Gemfile に devise とか bootstrap とか追加。あとから使うので fonts-awesome-sass も追加しておく。
ActiveStorage もちょっとよくわからないので、一旦使いなれた CarrierWave を使う方向で。
1 2 3 4 5 6 7 8 |
+ gem 'devise' + gem 'mini_magick' + gem 'carrierwave' + gem 'sprockets-rails' + gem 'bootstrap', '~> 4.3.1' + gem 'jquery-rails' + gem 'font-awesome-sass', '~> 5.9.0' |
追加した Gem のインストール
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ bundle install The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/............ Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.3.3 Using concurrent-ruby 1.1.5 Fetching io-like 0.3.0 Fetching execjs 2.7.0 Fetching bindex 0.8.1 Fetching ruby_dep 1.5.0 Fetching turbolinks-source 5.2.0 : : Post-install message from sass: Ruby Sass has reached end-of-life and should no longer be used. * If you use Sass as a command-line tool, we recommend using Dart Sass, the new primary implementation: https://sass-lang.com/install * If you use Sass as a plug-in for a Ruby web framework, we recommend using the sassc gem: https://github.com/sass/sassc-ruby#readme * For more details, please refer to the Sass blog: https://sass-lang.com/blog/posts/7828841 |
インストールの確認
webrick を使ってインストールの確認を実施
1 |
$ bundle exec rails s -b 0.0.0.0 |
いつもの画面が表示されればOK.