In this post I would to present You elementary Ruby configuration. You will get knowledge about Ruby installation and Rails configuration. This guide is for Linux operating system. To install ruby we will use rbenv.In linux we can install rbenv with this terminal command:
sudo apt install rbenv
Then we can install specific Ruby version (if you use this command without specific version, then rbenv install the newest Ruby):
rbenv install 3.0.2
Ok, now set default version to use in system:
rbenv global 3.0.2
And in last step we can check version of Ruby:
ruby -v
Result:
# ruby 3.0.2
That's it! We already have Ruby and then we can prepare to Ruby on Rails installation.
To run Ruby on Rails apllication we need Node.js. To install it we use this terminal comman:
sudo apt install nodejs
Now we need some database. Rails support a lot of databases (for example Firebird, MySQL, Oracle, PostgreSQL, SQLite, Microsoft SQL Server). We will use PostgreSQL. To install we have to run this command:
sudo apt-get install postgresql
And now we can install Rails framework. It is very simple. Just write:
gem install rails
Gems are something, like Ryby packages. We can use a lot of gems in one project. The most useful gems are for example devise (authentication gem) or cancan (authorization gem). So now we can check Rails version, like this:
rails --version
It shows current version of Rails framework. We can now creat project with Rails command:
rails new first_app
And now we can see that we have some new folders in the main app's catalog (I write about this in next post). We can run this application with command:
rails s
It means rails server. Now application is running on 3000, default port. To open application we have to write this address in web browser:
localhost:3000
Congratulations! 😀 You see the first Rails app. In next post, I will write about the structure of this project.