Skip to content

Instantly share code, notes, and snippets.

Models, Databases, Relationships in Rails

What is the difference between a primary key and a foreign key? Where would we find a primary key? What would it be called by default? Where would we find a foreign key? What is the naming convention for a foreign key?

Write down one example of:

  • a one-to-one relationship.
  • a one-to-many relationship.
  • a many-to-many relationship.
This file has been truncated, but you can view the full file.
  1. Define CRUD.

  2. There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.

  3. Why do we use set method_override: true?

  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.

  5. What are params? Where do they come from?

Feedback Sandwiches

  1. Positive! 🙂

  2. Constructive Feedback

  • I can tell that you're quick to pick up new things, but you sometimes leave me behind because I need a little more time to think about the problem that we're trying to solve. It would help me if you could explain your thinking and implementation frequently so that I can keep up and contribute.

  • I know you care a lot about this project, and sometimes when we get stuck on a feature for a while, I can see that you get really frustrated. Both of us care about submitting a high-quality project, but it would be more beneficial if we could take a break to cool off or try to destress in another way.

@Carmer
Carmer / git-workflow.markdown
Last active June 2, 2016 16:15 — forked from erinnachen/git-workflow.markdown
My Git Workflow

Project workflow:

  1. Load/Reload waffle.
  2. Choose a card from the backlog in waffle. If we're working separately, it's best to move that card that you've chosen into ready and perhaps assign it to yourself as well.
  3. git checkout master
  4. git pull origin master
  5. run your test suite
  6. Checkout a new branch and tag it with #issue_number
  7. Write the feature test associated with your waffle card.
  8. Run your test suite and make sure that there are no errors that blow up the stack (missing ends, forgetting capitalization, etc.)
  9. commit your feature test

Migration with ActiveRecord and Rails

Basic CLI commands

1.) Create a new table

  • rails g migration CreateTask title:string description:text
class AddStartDateToTask &lt; ActiveRecord::Migration

Mix Master Peer Review Session

This peer review session is aimed at practicing your ability to read code, communicate about your own and other peoples code, and give some practice in helping others troubleshoot their apps.

Things to cover:

  • First start with any issues or confusion the first partner may have had getting things to work. Try to troubleshoot things together if there is still a bug in your app. Here are some things you may want to consider:
    • The request response cycle
  • RSpec/testing

User model

  • Add password_digest to user model

rails g migration AddPasswordDigestTOUser rake db:migrate

Routes

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

Gif Generator:

  • Jen
  • Nick
  • Erin

Self-Directed

  • Marcella - Knitting-Revelry
  • Robbie - Trails/hikes
  • Anna - Trails/hikes
  • Kerry - Refuge donations app