前提・実現したいこと
Railsを使って簡単なマイクロポストのアプリを作成しています。ほとんどの機能の実装が終わり、残すところはRedisを使ってランキングを実装するだけになりました。
そこで調べてみるとRedisに関する(?)環境変数を.envファイルに記述する必要があるとのことでした。そこから再び自分で調べてみて、Gemをダウンロードして.envファイルを作ろうとしたのですが何回トライしてもファイルが作成されません…。
追記:先ほど調べてみたところ、MacOSXではドットから始まるファイル名を許可していないそうです。そこで次はmv env .envと言う風に一度envファイルを作成してから名前の変更を試みたのですが、コマンドを実行した瞬間ファイルが削除されダメでした。
発生している問題・エラーメッセージ
$ touch .env
上記のコードでファイルが作成されません。
該当のソースコード
Gemfile
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.5.3' 5 6gem 'devise' 7 8gem 'redis' 9 10gem 'dotenv-rails' 11 12# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 13gem 'rails', '~> 5.2.3' 14# Use sqlite3 as the database for Active Record 15gem 'sqlite3' 16# Use Puma as the app server 17gem 'puma', '~> 3.11' 18# Use SCSS for stylesheets 19gem 'sass-rails', '~> 5.0' 20# Use Uglifier as compressor for JavaScript assets 21gem 'uglifier', '>= 1.3.0' 22# See https://github.com/rails/execjs#readme for more supported runtimes 23# gem 'mini_racer', platforms: :ruby 24 25# Use CoffeeScript for .coffee assets and views 26gem 'coffee-rails', '~> 4.2' 27# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 28gem 'turbolinks', '~> 5' 29# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 30gem 'jbuilder', '~> 2.5' 31# Use Redis adapter to run Action Cable in production 32# gem 'redis', '~> 4.0' 33# Use ActiveModel has_secure_password 34# gem 'bcrypt', '~> 3.1.7' 35 36# Use ActiveStorage variant 37# gem 'mini_magick', '~> 4.8' 38 39# Use Capistrano for deployment 40# gem 'capistrano-rails', group: :development 41 42# Reduces boot times through caching; required in config/boot.rb 43gem 'bootsnap', '>= 1.1.0', require: false 44 45group :development, :test do 46 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 47 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 48end 49 50group :development do 51 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 52 gem 'web-console', '>= 3.3.0' 53 gem 'listen', '>= 3.0.5', '< 3.2' 54 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 55 gem 'spring' 56 gem 'spring-watcher-listen', '~> 2.0.0' 57end 58 59group :test do 60 # Adds support for Capybara system testing and selenium driver 61 gem 'capybara', '>= 2.15' 62 gem 'selenium-webdriver' 63 # Easy installation and use of chromedriver to run system tests with Chrome 64 gem 'chromedriver-helper' 65end 66 67# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 68gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 69
試したこと
touch .envコマンドでのファイル作成以外には特に取り組んでいません。初心者なので誤ってアプリを台無しにしてしまうかもしれないと思ったからです。
補足情報(FW/ツールのバージョンなど)
ruby 2.5.3
rails 5.2.3
補足ですが、最終的に達成したい目標はRedisを使用してアプリ内にランキングを表示することです。もし.envを使わずに実装する他の方法があれば、ご教授願いたいです。
野暮な質問かもしれませんが、どうぞよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー