I started to develop a new application with Ruby on Rails 6 (RoR). It has been a while since the last time I started a project with a cutting-edge RoR version, so I took the opportunity to dig a little bit about “the good, the bad and the ugly” about RoR and Ruby in general.
Looks like everybody agrees that is not dead, just not a “new toy” like it was 15 years ago, but still in pretty good shape. Some new tricks, but when I started to use it, it looks and feels quite the same, what made me happy. And, I read a lot of mentions about the new coming Ruby 3, looks like Ruby developers are promising in a near future to triplicate the speed which always has been the “but” of this language; we’ll see, we’ll see.
So I created a new Project to have a better opinion about it. I did on a Linux subsystem on Windows 10. There is a great article about how to have it installed in no time in your machine here . It’s fast, don’t add unneeded steps and it works, so why to spend time in telling you the same.
After that just open a bash console, and let’s start typing, first some common prerequisites to have Ruby and Ruby on Rails working.
# Updating everything sudo apt-get update # getting some needed packages sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev postgresql- client-common postgresql-client libpq-dev
Now let’s install Ruby with renv.
cd git clone https://github.com/rbenv/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL
Now it will install the latest Ruby version, in my case 2.7.1. (It can take a little while, just be patient)
rbenv install 2.7.1 rbenv global 2.7.1 # checking ruby version ruby -v
Let’s install Ruby’s package manager, Bundler, it will make your life so easy when installing gems and keeping track of everything installed. Believe me.
gem install bundler rbenv rehash
Rails is dependent on NodeJS so we will need to have it installed first.
# NodeJS mapped curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - # installing NodeJS sudo apt-get install -y nodejs # checking nodejs -v
Final step, install Rails:
gem install rails rbenv rehash # checking.... rails -v
Done! We did it!!!!
Just in case you want to have PostgreSQL although MySQL works like a charm with Ruby on Rails.
Lets download and install the latest stable version of PostgreSQL Windows binary.
PostgreSQL 9.6.2 provided by BigSQL: Download
After all the installation steps, open a bash terminal and run:
psql -p 5432 -h localhost -U postgres # to exit the psql console, just type \q
So these are the minimum steps to have Rails working in your Windows 10 machine under Linux system. Not so many and quite straight forward.