Building a Reddit Clone Pt.1

I have read forums and asked alot of people what to do after learning Ruby on Rails quite a bit. Most of them suggested to start my own web app. Allthough i really want to start creating and realising my ideas , i dont feel comfortable enough to not have someone guiding me through the process. I feel like i want to first start recreating stuff others have built allready. I’ve found a few good tutorials on Youtube, especially Mackenzie Child ‘s 12 in 12 challenge , where he would create 1 app in 1 week to teach himself to code Ruby on Rails.

Im going to follow along his tutorial and summarize what i found the most noticeable, starting with: “How to build a Reddit or Hacker News Style Web App in Rails 4”




At first its important to think about what features our app should have. We want users to share links with each other, so the first step would be to:

creating a new rails app with:

rails new raddit

generating a scaffold with:

rails g scaffold link title:string url:string

#the scaffold command created a link model for us and some views

update the database with:

rails db:migrate


As always we should put our app under version control with Git:

git init 

#initializes a new git repository

git add .

#adds all new or changed files to the staging phase

git commit -m “generated link scaffold”

#commits the files with notes


We also want users to sign in and out. The gem ‘Devise’ is just perfect for that.

git checkout -b add_users

#switches to a new branch

To install Devise we need to paste: gem ‘devise’, ‘~> 4.2’ into our Gemfile,

and run: bundle install in our command line. To finish the installation, we need to run:

rails g devise:install

We still to make some changes to our files such as pasting:

config.action_mailer.default_url_options = { host: ‘localhost’, port: 3000 } 

secondly adding a root route in our routes.rb file should be done:

Rails.application.routes.draw do
resources :links

root to: “links#index” #defining the root url

thirdly we need to add a flash message in our application.html.erb file with:

<p class=“notice”><%= notice %></p>
<p class=“alert”><%= alert %></p>


In the last step we want to generate Devise views to customize them:

 rails g devise:views


Having finished the whole installation process we can generate our first user with Devise:

rails g devise User

#creates a user model and migration for us

and migrate again with:

rake db:migrate


We can now create users in the browser, they can sign up and sign in.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s