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:
- rails generate
- rails destroy
- If you are not clear on how to edit a resource, take a look over this section of the rails guides.
- Ffaker Gem - for seeding the database.
- Rails Guides - everything you need to know to start up a new rails app.
- Views glossary
- auth tutorial
START THE TIMER! You have 3 hours!
- Create your rails app in a directory like
trial1
,trial2
,trial3
. - Use git properly: commit as you go!
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 attributesemail
,first_name
,last_name
,password_digest
- We need authentication in our
user
model, i.e.User.confirm
andsecure_password
- an
article
modeltitle
andcontent
- simple validations on the title and content for presence
- a
- We need one association
- 1 to Many:
user
andarticle
- 1 to Many:
- 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 leastnew
andcreate
. - We need
session_helper
methods forlogin
,logged_in?
,logout
, andcurrent_user
.
With all of the above users
should be able to do the following:
users
cansign_up
users
canlogin
users
canlogout
users
can view, create, and edit articles once logged in.users
can onlyedit
,update
, anddestroy
their own articles - this might be a CHALLENGE.
Go back through your application and create partials for your nav, login/signup forms, and any other areas with significant repetition in your html.
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!
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
.
- GIANT LIST OF AWESOME GEMS
- CLICK BAIT
- Rails 4.2 Release Notes
- Rails 4.1 Release Notes
- Rails 4.0 Release Notes
- Rails 4 Stuff
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