Skip to content

paircolumbus/BitlyClone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Bitly Clone

Skill Level: Intermediate
Time Limit: 1-2 hours

Bitly.com is a link shortening service that provides people with a way to take really long urls and turn them into short urls for easy use in email and social media. Today, you'll create a clone.

Note: If you have scant Rails knowledge, we highly recommend tackling TasksApp or following the Rails Getting Started guide when attempting this drill.

For this challenge, you may ONLY use the controllers provided to you in the source folder.

Release 0: Simple Shortener

We have one resource: Urls. For our controllers, we have a URL that lists all our Url objects and another URL that, when POSTed to, creates a Url object.

We'll also need a URL that redirects us to the full (unshortened) URL. If you've never used bitly, use it now to get a feel for how it works.

  • Use a before_save callback in the Url model to generate the short URL.
  • Make sure to use RESTFUL routes

Release 1: Add a Counter!

Add a click_count field to your urls table, which keeps track of how many times someone has visited the shortened URL. Add code to the appropriate place in your controller code so that any time someone hits a short URL the counter for the appropriate Url is incremented by 1.

Release 2: Add Validations

Add a validation to your Url model so that only Urls with valid URLs get saved to the database.

A valid URL is...

  • Any non-empty string
  • Any non-empty string that starts with "http://" or "https://"
  • Any string that the Ruby URI module says is valid
  • Any URL-looking thing which responds to a HTTP request, i.e., we actually check to see if the URL is accessible via HTTP

Release 3: Add Error Handling

Display a helpful error message if a user enters an invalid URL, giving them the opportunity to correct their error.

EXTRA CREDIT - Add User Authentication

Create one model, User to handle both regular users and at least one administrator. Your controllers should support a few core actions:

  1. Logging in
  2. Logging out
  3. Creating an account
  4. Viewing the secret page
  5. Redirecting a user back to the "log in" screen if they try to view the secret page without being logged in

Resources

About

A link shortener drill that exposes basic Rails functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published