Giter Site home page Giter Site logo

bachtsui / rails-drills-to-crud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sf-wdi-25/rails-drills-to-crud

0.0 1.0 0.0 65 KB

Build 4 apps - one of these things is not like the other

Ruby 73.44% JavaScript 1.93% CoffeeScript 2.05% CSS 3.73% HTML 18.84%

rails-drills-to-crud's Introduction

Rails Review

Weekend Mini-Lab: Time Trials

Objective
Your goal is to build this project from scratch at least three times this weekend. Attempt to complete the following functionality within three hours with an eventual target time of under two hours.

NOTE: Please use a timer to time yourself when working on part 1. You'll be doing part 1 at least three times! Please have your two best times recorded and ready to share on Monday, and have notes of questions that came up when doing this process.

Each time you do this, create your rails app in a new directory like trial1, trial2 or trial3.

NOTE: See below for submission instructions.

Resources:




START THE TIMER! You have 3 hours!




Part 1. Blog Time Trials

  • Create your rails app in a directory like trial1, trial2, trial3.
  • Use git properly: commit as you go!

Models

Use the following when constructing a blog. You should not add styling or anything extra during time trials. This is barebones functionality.

  • We need 2 models
    • a user model with the following attributes
      • email, first_name, last_name, password_digest
      • We need authentication in our user model, i.e. User.confirm and secure_password
    • an article model
      • title and content
      • simple validations on the title and content for presence
  • We need one association
    • 1 to Many: user and article

Controllers & Views

  • We need a users controller with all seven resources
  • We need an articles controller with all seven resources
  • We need a sessions controller with at least new and create.
  • We need session_helper methods for login, logged_in?, logout, and current_user.

Authentication & Authorization

With all of the above users should be able to do the following:

  • users can sign_up
  • users can login
  • users can logout
  • users can view, create, and edit articles once logged in.
  • users can only edit, update, and destroy their own articles - this might be a CHALLENGE.

Partial It Up

Go back through your application and create partials for your nav, login/signup forms, and any other areas with significant repetition in your html.

Seed Your Application

Add the ffaker gem to your Gemfile and use it in your db/seeds.rb file to create fake users and associated articles, here's a cheatsheet for it.

/db/seeds.rb

# create 100 users
100.times do

  # build the user params
  user_params = Hash.new
  user_params[:email] = Faker::Internet.email
  user_params[:email_confirmation] = user_params[:email]
  user_params[:password]  = "123456"
  user_params[:password_confirmation] = user_params[:password]
  # save the user
  new_user = User.create(user_params)

  # create 10 articles for each user
  10.times do
    new_article = Article.new
    new_article.title = Faker::HipsterIpsum.words(rand(8)+2).join(" ")
    new_article.content = Faker::HipsterIpsum.paragraphs(1+ rand(4)).join("\n")
    # save the article
    new_article.save
    # associate the article with the user
    new_user.articles.push new_article
  end

end



STOP THE TIMER! Record your time and how far you got! Take a break. When you're ready, do it all over again! If you're still under three hours, you may push onward into part 2!




Part 2. CRUD anything

Objective: Make something in Rails using all the aspects of CRUD. It's up to you to come up with an idea, but it must have a model, views, controllers, and routes to create, read, update and delete at least one resource. You also need at least one relationship.

NOTE you don't need to add users and authentication. Actually, don't add authentication just to fulfill the CRUD requirement because that would be boring.

You must use bootstrap or your own (thorough) custom styling.

In addition, you are required to use a gem or feature of Rails which hasn't been covered explicitly in class.

Finally, please create this rails app in a directory named: crud_app.

Example Gems or Rails Features

Getting started & Submission

Fork and clone this repository. Change the readme.md to reflect what your project does, and then submit a pull request back to this repo once you're done.

Your PR should include 4 directories/rails-apps:

  • trial1
  • trial2
  • trial3
  • crud_app

rails-drills-to-crud's People

Contributors

bachtsui avatar tgaff 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.