In this post, I will shortly describe how to jumpstart Ruby on Rails based project. I am building a project called Finance Grinder and I’ll show you steps, that needs to be done to create new app. Also, I will describe gems (libraries), that I’ve chosen to use in my app.
How to start with Ruby on Rails
(programming language) with its most popular framework Rails
don’t require many complicated steps, to start working with. You also don’t need to download gigabytes of software to install.
The Internet is full of detailed articles, tutorials, and videos about starting with RoR, so I will mention the most important, and show how I did it.
Step 1. Choose operating system
You might be a little bit surprised of starting with that, but this is important. When you spend some time working with rails projects, you will know why.
Before ruby and rails installation you’ll need to the give effort to choose proper operating system. The best choice will be Linux or MacOS. Why not Windows? Well, it is true that all packages necessary to start can be installed on Windows (http://rubyinstaller.org
), but sooner or later, I’m sure you’ll experience problems so frustrating, that you’ll switch to other OS. Therefore, better immediately install Linux on the separate partition or on a virtual machine.
I recommend Ubuntu. Maybe it is not the fastest, but most popular distribution.
Step 2. Installation of Ruby Version Manager
Before you’ll install ruby I recommend you to install Ruby Version Manager (RVM). This is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. That’s a fair description from their site. To install it just run in the command line:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
Step 3. Installation of Ruby On Rails
Now you can easily install the most important packages. First, you need to start with Ruby, so run a command:
RVM will download ruby, and install it. When the installation is completed you can verify it by running
. You should receive a version of installed ruby. Before rails installation, you need to select ruby in RVM and point namespace (RVM call it gemset) to install all gems (yes, rails also is a gem). You can grant your specific name to gemset. I will name it by name of my project (finance_grinder).
rvm use 2.4.0 --default
rvm create gemset finance_grinder
rvm use gemset finance_grinder
Now RVM knows where to store all libraries for your project, so install most important of them – rails:
This command will install Rails framework with its dependencies, so it will take a while. Once it will be finished check if it went correctly by running
rails -v . It should return a number of newest version, for today it’s 5.0.2.
Before you fire up a new project, you need to install Bundler. It is a tool to manage, track and install exact versions of gems that are needed. Bundler
is some sort equivalent to Composer for PHP or npm for Node.js.
Step 4. Creating new, SHINY Rails project
Rails comes with a very handy package of generators, one of them is new project command:
rails new finance_grinder
After hitting the enter button, rails will generate all files for the project, ready to start. Automatically bundler will install all dependencies.
That’s it, your project is ready to be developed, you can even run it now:
Once the server is started, open browser and go to localhost:3000
. You should see starting image:
Step 5. Installing favorite gems
This is not a necessary part to proceed with your project. I will install gems, which I like most, and remove preinstalled some from the project. You can see these modifications in my project repository: https://github.com/sampi60/finance_grinder
Changes I’ve made:
- Change database engine. Replace ‘sqlite3’ by ‘pg’. Some setup with PostgreSQL is also needed, but I will not cover it in this post.
- Replace ‘byebug’ by ‘pry’. I just like it more, but it has the same main functionalities.
- Use ‘rspec’ instead built in UnitTest for tests. Also add awesome gems such as: ‘rails-controller-testing’, ‘factory_girl_rails’, ‘faker’, ‘shoulda-matchers’ and ‘capybara’. These are ones of most used gems by rails developers, so I encourage you to get familiar with them and give them a try.
- ‘better_errors’ – to see clearly what I’ve broken 🙂
- ‘binding_of_caller’ instead ‘web-console’ to play with application on error screen
- Add powerful ‘devise’ gem to deal with users authentication.
- Add MaterialiceCSS framework. This is an experiment, I’ve never used it, but I always wanted to.
After each change in ‘Gemfile’ file you need to run
bundle install or just
bundle command to install new gem and make update ‘Gemfile.lock’ file.
That’s it for now. I have some favorite gems for other purposes. I will probably add them during development, or I will give a try to equivalent ones, or maybe try to build my own solutions. Will see.
Unfortunately, until now I haven’t done anything except this because I wanted to describe the process of installing environment and running new rails project. My actual goal is to catch up with code, so I rather wouldn’t cover any commit so closely.
I will try to report Finance Grinder status at every beginning of a week, announce what I did, and what I will focus on during next 7 days. I hope that such exact plan allow me to work efficiently if only I will have time.
Stay tuned, see what will happen, and don’t hesitate to leave some feedback!