How to generate a new rails app with a specific Rails version


Introduction


Goal

My goal is to create a new app with the 5.2 Rails version.


Make sure you have Ruby installed

rbenv versions
ruby -v


Check the current installed Rails versions

gem list rails --local

Output

If you get nothing, it's because there's no Rails version associated with your current Ruby version.


List valid Rails versions

gem search '^rails$' --all

Output


Install the desired Rails version

gem install rails -v '5.2' -V --no-document

Output


Check the current installed Rails versions

gem list rails --local

Output


Double check the version

rails -v

Output


Rehash the directory

rbenv rehash

Output


Create the app

rails _5.2.0_ new myapp-backend --api

Output


Check the new app

cd app_name


Done


Celebrate

The It Crowd Birthday GIFs | Tenor


Reach me out


Final thoughts

Thank you for taking the time to read our article.

If you have any questions, thoughts, suggestions, or corrections, please feel free to share them with us.

Your feedback is valuable, and we eagerly anticipate hearing from you.

Don't hesitate to suggest topics for future blog articles. Until next time!