Coder Social home page Coder Social logo

ritly's Introduction

GeneralAssemb.ly

Time to review. You now have all the necessary knowledge to build a small Rails app. Let's build!

#Ritly

We are going to build an app similar to Bitly, called Ritly. The challenge is going to be understanding the flow of control in a Rails app.

Instructors demo the app for students.

Here is a brief overview of the app.

  • Visitors to Ritly will be able to request a randomly generated code for their URL link and save it to the database.
  • Visitors to Ritly can go to localhost:3000/<CODE>, where <CODE> is a randomly generated code, and the application will redirect them to the matched link in the database.
  • Visitors to Ritly can go to localhost:3000/<CODE>/preview, and the app will preview the matching URL link from the database.

###Task Instructions

We are going to challenge your understanding of a Rails app. With the demo, description above and hints below build Ritly.

Here are a few hints.

####The URLs Table

id link hash code created at updated at
1 http://www.generalassemb.ly 516396 Wed, 19 Jun 2013 21:23:30 UTC +00:00 Wed, 19 Jun 2013 21:23:30 UTC +00:00
2 http://www.google.com 234687 Wed, 19 Jun 2013 21:25:32 UTC +00:00 Wed, 19 Jun 2013 21:25:32 UTC +00:00
3 http://www.bustedtees.com 093674 Wed, 19 Jun 2013 21:23:30 UTC +00:00 Wed, 19 Jun 2013 21:23:30 UTC +00:00

####The routes.rb file

		Ritly::Application.routes.draw do
			root "home#index"
			resources :urls #TODO: restrict this to just :create, :new and :show

			get '/:code', to: 'urls#redirectors'
			get '/:code/preview', to: 'urls#preview'
		end

####The Views

  • show.html.erb
    • Visitors are redirected to the show page after they request a randomly generated code for their URL link.
    • Displays the random code that was generated: "Your code is: random_code" Go to localhost:3000/random_code to visit your URL.

####Generating a Random Number or Hash

  • To generate a random number in Ruby: rand(10000).
  • Bonus Use SecureRandom.urlsafe_base64(8) to generate a random hash code.

Remember, Google is your friend!

#Rewsly

###App Description

The City Times needs an app and has hired BEWD students to build it. They want to enter the 21st century and move their print newspaper online.

You will build Rewsly during lesson 11 & 12.

Here are the features needed by next class.

For now City times is only interested in linking to other news sources instead of writing their own news.

  • The front page welcomes visitors "Welcome to Rewsly" and list all titles in the stories table.
  • Visitors can view a story's upvotes, category and link to more details by clicking on the title from the front page.
  • Visitors can search for a specific story by title and category from the front page.
  • Visitors can add stories to the database if all fields are present.
    • Prevent visitors from saving a record if it has errors.

We've supplied you with story seeds.

Bonus

  • Only display stories with 4 or more upvotes on the front page.
  • Only display stories created today on the front page.

Remember, Google is your friend!

Happy coding :)

ritly's People

Contributors

taiwoayanleye avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.