apt install curl git gnupg2 nodejs
Go to the site rvm.io and look at the installation commands:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB curl -sSL https://get.rvm.io | bash -s stable
Add a user to the group:
My username in the system – ubuntu
Then from the user:
Find out the version of RVM:
View a list of Ruby versions available for installation:
rvm list known
Install the latest version of Ruby:
rvm install "ruby-2.5.1"
The list of installed Ruby versions and the default can be found as follows:
Let’s see the gem version and update it:
gem -v gem update --system
gem install rails
Create a test application:
rails new example_app -T
Go to the directory of our application:
Let’s create for the test index.html
Insert there the following:
<!DOCTYPE html> <html> <head> <title>Ruby</title> </head> <body> Example Ruby App </body> </html>
Run for test on all interfaces:
bundle exec rails s -p 3000 -b '0.0.0.0' => Booting Puma => Rails 5.2.2 application starting in development => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop
Check in the browser:
Where 220.127.116.11 is the IP address of the computer where the application is running
If the computer has a graphical shell, you can omit the IP address when launching the application, and enter the browser by localhost. Also without graphics, the localhost can be checked with a cursor or a console browser.
You can stop the application – Ctrl-C
Being in the root of our application, we initialize the repository:
git init Reinitialized existing Git repository in /home/ubuntu/heroku/example_app/.git/
git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore .ruby-version Gemfile Gemfile.lock README.md Rakefile app/ bin/ config.ru config/ db/ lib/ log/ package.json public/ storage/ tmp/ vendor/ nothing added to commit but untracked files present (use "git add" to track)
Add all files:
git add .
And we are doing a commit:
git commit -am "Add Ruby files to repo"
We register on heroku.com and go to the account.
For the convenience of working with Heroku, install their CLI
sudo snap install --classic heroku
Installation for distributions other than Ubuntu can be viewed on the website Heroku
heroku --version heroku/7.19.4 linux-x64 node-v11.3.0
Log in to Heroku CLI:
We press any key and get the authorization URL, copy it to the browser, log in.
Let’s create an application on Heroku:
heroku create Creating app... done, ⬢ my-generated-app-name-83844 https://my-generated-app-name-83844.herokuapp.com/ | https://git.heroku.com/my-generated-app-name-83844.git
Now in the Gemfile it is necessary to replace "sqlite3" with "postgres", otherwise Heroku will give the following error:
remote: An error occurred while installing sqlite3 (1.3.13), and Bundler cannot remote: continue. remote: Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling. remote: remote: In Gemfile: remote: sqlite3 remote: remote: ! remote: ! Failed to install gems via Bundler. remote: ! Detected sqlite3 gem which is not supported on Heroku: remote: ! https://devcenter.heroku.com/articles/sqlite3 remote: ! remote: ! Push rejected, failed to compile Ruby app.
Find at the beginning of the file record of sqlite3
And we transfer it to the block "group :development, :test do"
To get the following:
group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'sqlite3' end
Before this block, add a new block:
group :production do gem 'pg' end
Save changes to the file.
Reinstall without postgres.
bundle install --without production
Add files, commit and push to Heroku:
git add . git commit -am "Heroku" git push heroku master
In response, we get the URL by which we can check the application on Heroku.