It is a learning record. If you proceed as it is, there will be some parts that will get stuck, so I will write about the correspondence.
https://railsgirls.jp/install
gem install rails --no-document
rails -v
When specifying the version
gem install rails -v 5.1.6
Created by specifying the version with a command.
rails _5.1.6_ new hello_app
cd hello_app
Gemfile
Package management file.
The package seems to be downloaded locally.
If you write a package that is not locally and bundle install
, you will get an error.
It seems that bundle update
downloads packages that are not local.
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.1.6'
# Use Puma as the app server
gem 'puma', '3.9'
# Use SCSS for stylesheets
gem 'sass-rails', '5.0.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '3.2.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '4.2.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '5.0.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '2.6.4'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'jquery-rails', '4.3.1'
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
group :production do
gem 'pg'#, '0.20.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
bundle update
bundle install --without production
Since an error occurs when installing sqlite, refer to the following article. https://qiita.com/shuhey/items/8cd28aed5906fb5fa6ec
rails server
The usual.
Browser
|
Controller - Model
| |
View Database
app/controllers/application_controller.rb
def hello
render html: "hello world!"
end
config/routes.rb
Rails.application.routes.draw do
root 'application#hello'
end
See the following article. https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39
In the initial state, sqlite is used, but Heroku does not support sqlie. Heroku uses postgres, so rewrite production to postgres.
config/database.yml
production:
<<: *default
adapter: postgresql
encoding: unicode
pool: 5
heroku create
git add .
git commit -m "Initialize"
git push heroku master