Photo by Joshua Fuller on Unsplash
Unleash the Power of Ruby on Rails: A Step-by-Step Guide to Running Your App Locally!
I have heard of Ruby on Rails but have yet to use it.
I applied for a role and was assigned a Ruby on Rails task.
The task was to click a button, and a new tab would open, showing mail details with the help of a gem letter opener.
We were encouraged to google to help with the task for those that didn't know Ruby on Rails.
I had an assigned repository to push my code to. The Repository already contained the app's User-interface, so I had to add the functionality.
I have never done anything with Ruby on Rails, so running the app on my local system was new. The steps I took to run the Ruby app on my system are below.
Step-by-Step Guide to Running Your App Locally!
The steps to running a Ruby on Rails app on your local machine may differ. I am using a Mac, and the steps may be different.
Step One
Install Homebrew using the command below.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Homebrew helps to install and compile software packages easily.
Step Two
Install rbenv
rbenv helps to manage our ruby versions.
brew install rbenv ruby-build
Step Three
You will use the commands below to add rbenv to the terminal to load whenever you open a terminal.
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
source ~/.zshrc
Step Four
Install Ruby
Finally, you get to install Ruby. You are installing the latest version, 3.2.2
rbenv install 3.2.2
Step Five
Set the default version
rbenv global 3.2.2
Step Six
Confirm the version you just installed using the command below
ruby -v
Step Seven
Install Rails
you are installing the latest version, 7.0.4.3
gem install rails -v 7.0.4.3
Step Eight
rbenv rehash
Run the command above to tell rbenv to see Rails so you can use it.
Step Nine
Clone the repo. I am cloning the repository assigned to me for the task.
git clone https://github.com/fly-hiring/57792.git
Step Ten
bundle install
You will use bundle install to install the dependencies of a Ruby on Rails project.
If you come from a javascript background, bundle install is like installing dependencies using npm install after cloning a project.
Step Eleven
rails server
Run the rails server to start your app
Conclusion
The process of running a Ruby on Rails app on your system may differ slightly from mine, but you can check out this guide that helped me.
Happy Coding!!!