I Built a Free URL Shortener in 48 Hours Using Ruby on Rails — Here's Why Rails Still Rocks in 2025
The Problem That Started It All
Yesterday, I was working on an article about my Elixir project. I needed to share multiple long URLs in the post, so naturally, I reached for a popular URL shortening service.
Three clicks later, I hit a wall: "You've reached your limit of 3 short links this month."
As a developer, this felt wrong. Why should something as simple as shortening URLs be locked behind paywalls and limits?
So I did what any developer would do: I built my own.
48 hours later, I had a fully functional, free, open-source URL shortener deployed and running.
Why Ruby on Rails?
In 2025, with all the new frameworks and tools out there, why would I choose Rails?
Simple answer: productivity.
Rails is built on the principle of "convention over configuration" — which means less time configuring, more time building. Here's what I got out of the box:
⚡ Speed of Development
rails new url_shortener -d postgresql
rails generate scaffold Link original_url:text short_code:string clicks:integer
rails db:migrate
Three commands. That's it. I had a full CRUD application with:
- Database schema
- RESTful routes
- Controller actions
- View templates
🎯 Smart Defaults
Rails made architectural decisions for me, so I could focus on the unique business logic:
class Link < ApplicationRecord
before_create :generate_short_code
private
def generate_short_code
loop do
self.short_code = SecureRandom.alphanumeric(6)
break unless Link.exists?(short_code: short_code)
end
end
end
Six lines of code to generate unique short codes. No external libraries needed.
📦 The Ruby Ecosystem
Need QR codes? There's a gem for that:
gem 'rqrcode'
One line in the Gemfile, and suddenly I could generate QR codes for every short link:
RQRCode::QRCode.new(short_url).as_svg
What I Built
The URL shortener includes:
- Instant Short Links - Paste a URL, get a short code
- Click Analytics - Track how many times each link is clicked
- QR Code Generation - Automatic QR codes for every link
- No Registration Required - Anyone can use it freely
- Clean, Responsive UI - Built with inline CSS (no framework bloat)
The Technical Stack
- Backend: Ruby on Rails 8.1
- Database: PostgreSQL
- QR Codes: rqrcode gem
- Deployment: Render (free tier!)
- Time to MVP: Less than 48 hours
Why Rails Made This Possible
1. Active Record Is Magic
Rails' ORM (Active Record) turned database operations into elegant Ruby code:
@link = Link.find_by!(short_code: params[:short_code])
@link.increment!(:clicks)
redirect_to @link.original_url
No SQL, no boilerplate — just readable, maintainable code.
2. Database Migrations Are First-Class Citizens
Every schema change is versioned and reversible:
class CreateLinks < ActiveRecord::Migration[8.1]
def change
create_table :links do |t|
t.text :original_url
t.string :short_code
t.integer :clicks, default: 0
t.timestamps
end
add_index :links, :short_code, unique: true
end
end
3. Convention Over Configuration
Rails assumes sensible defaults. Want a redirect route?
get '/:short_code', to: 'links#redirect'
One line. Rails handles the rest.
4. Deployment Is a Breeze
With Render, deploying Rails apps is ridiculously simple:
- Connect GitHub repo
- Add environment variables
- Hit deploy
Rails' convention-based structure means Render knows exactly how to build and run the app.
The Results
Live URL: [Your Deployed URL]
Source Code: [GitHub Repository]
The project is:
- ✅ 100% free to use
- ✅ Open source (MIT license)
- ✅ Deployable in 10 minutes
- ✅ No registration required
- ✅ Fully functional with analytics and QR codes
Lessons Learned
1. Rails Still Delivers on Its Promise
After nearly 20 years, Rails remains one of the fastest ways to build web applications. The "Rails way" isn't just convention — it's accumulated wisdom from thousands of production apps.
2. Choose Boring Technology
Rails isn't trendy. It doesn't make headlines at tech conferences. But it works, and it works consistently.
When you need to ship fast, reach for boring, proven technology.
3. Open Source Wins
Instead of paying for limited features, I built exactly what I needed and made it available for everyone. That's the power of open source.
Try It Yourself
The entire project is open source. You can:
- Use the live version at [Your Live URL]
- Deploy your own in under 10 minutes
- Fork and customize to fit your needs
- Contribute features via pull requests
Final Thoughts
In 2025, with AI, microservices, and serverless everything competing for our attention, it's easy to overcomplicate things.
Sometimes, the best solution is the simplest one.
Rails gave me superpowers: I went from idea to deployed product in 48 hours, with clean code, zero configuration headaches, and a fully functional app.
That's the Rails magic that keeps me coming back.
What's your experience with Rails? Or what framework do you reach for when you need to ship fast? Let me know in the comments!
Resources
📂 GitHub Repository: https://github.com/aliabdm/url-shortener-rails
🚀 Live Demo: https://url-shortener-rails.onrender.com/links
💼 Connect on LinkedIn:https://www.linkedin.com/in/mohammad-ali-abdul-wahed-1533b9171/
🐙 Follow on GitHub: https://github.com/aliabdm
If you found this helpful, give the project a ⭐ on GitHub!
Built with ❤️ using Ruby on Rails
Top comments (0)