I've finally gone around the Rails tutorial. As the next step, I've summarized only the setup related items in order to create an original Web service while referring to the Rails tutorial. The development environment is Cloud9.
A command (apparently) that specifies not to install documents on a regular basis. I was allowed to reference. [Disassemble "$ printf" install: --no-document \ nupdate: --no-document \ n ">> ~ / .gemrc" in Chapter 1 of the Rails tutorial](https://qiita.com/nodenanode/ items / 11a34144533654a5c024)
$ printf "install: --no-document \nupdate: --no-document\n" >> ~/.gemrc
This time, I left the version as a tutorial, but I have to upgrade it someday. .. ..
$ gem install rails -v 5.1.6
$ rails _5.1.6_ new "title"
$ cd ~/envronment/"title"
$ git init
$ git add -A
$ git commit -m "Initialize repository" #Comments are standard
After creating a repository with'New repository'on GitHub, execute the following command (URL is described in the repository creation screen)
$ git remote add origin "URL"
$ git push -u origin master
#Set origin master as upstream branch with u option
#From the next time, you can push to origin master only with git push
If you want to keep the repository private, click Make private in the'Danger Zone'at the bottom of the Setting.
$ cd ~/.ssh #Move to the folder to put the key
$ ssh-keygen -t rsa #Generate key
$ cat id_rsa.pub #View the contents of the key and copy manually
#I couldn't use pbcopy in cloud9, so I'm copying it manually.
Set public key at https://github.com/settings/ssh Check the connection with the following command, and if the following comment appears, the connection is complete.
$ ssh -T [email protected]
Hi (account name)! You've successfully authenticated, but GitHub does not provide shell access.
I was allowed to reference. Procedure for ssh connection on GitHub ~ From generation of public / private key ~
You may get the following warning (I got it). Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.x' to the list of known hosts.
It doesn't mean that you can't push, so there seems to be no problem, but it's unpleasant to see Worning. .. .. The following command updates the contents of known_hosts and Worning disappears.
$ ssh-keygen -R "IP address"
#If the above doesn't help, try the following commands as well
$ ssh-keygen -R github.com
$ git remote set-url origin "URL"
#Do the following for confirmation
$ git remote -v
#Git as [email protected] if it starts from com!
origin [email protected]:reiji012-pg/Tabetter.git (fetch)
origin [email protected]:reiji012-pg/Tabetter.git (push)
For the time being, leave the tutorial as it is. Install PostgreSQL gem only in production environment
Gemfile.
group :production do
gem 'pg', '0.20.0'
end
Install SQLite gem in development and test environment
Gemfile.
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
Install with options not to install pg gem in production environment
$ bundle install --without production
Install Heroku
$ source <(curl -sL https://cdn.learnenough.com/heroku_install)
After confirming the installation, from login to deployment.
$ heroku --version
$ heroku login --interactive
$ heroku keys:add
$ heroku create
$ git push heroku master
You can change the name of the application with the following command
$ heroku rename "Application name"
Heroku settings disappear every time I start the terminal It can be solved by setting the file that describes the path to heroku to be executed every time the terminal is started. Insert all of the following with the vi command at the bottom of the file
~/.bashrc
PATH=/usr/local/heroku/bin:$PATH
~/.bash_profile
source ~/.bashrc
Modify the following files (commented out, just uncomment)
config/environments/production.rb
config.force_ssl = true
Replace Heroku's web server with Puma from the default WEBrick (Because it cannot handle significant traffic and is not suitable for production environments)
Just uncomment what is also commented out
config/puma.rb
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
This is a new file (./Procfile)
web: bundle exec puma -C config/puma.rb
For the time being, I think we have created an environment where we can start creating applications.
Recommended Posts