Skip to content

Instantly share code, notes, and snippets.

View dohoonk's full-sized avatar
🎯
Focusing

Tony(Dohoon) Kim dohoonk

🎯
Focusing
View GitHub Profile
@dohoonk
dohoonk / day16.md
Created February 2, 2016 03:25
codecore

RUBY and SINATRA review

Difference between module and class

What protocol stack powers the web?

What is REST?

what protocol does it depend on?

When to use POST and GET

@dohoonk
dohoonk / day17.md
Last active February 3, 2016 17:13
codecore

bin/rails g migration add_indicies_to_questions

bin/rake db:migrate

bin/rails c

validates :title, presence: true

q.erros

@dohoonk
dohoonk / day18.md
Created February 3, 2016 19:42
codecore

bin/rails c "question".pluralize

bin/rails generate questions

make sure you can access the page

get "/questions/new" => "questions#new", as: :new_questions

@dohoonk
dohoonk / amazon.md
Last active February 3, 2016 21:27
Step Guide to creating Amazon example

1.rails new amazon -t create project in rails

2.bin/rake db:create create database

3.bin/rails generate model product name:string description:text 'price:decimal{10,2}' this generates modle

4.bin/rake db:migrate

1.get "/questions/:id" => "questions#show", as: :question

2.create control method def show @question = Question.find params[:id] end

3.create view page

@dohoonk
dohoonk / day19.md
Created February 5, 2016 04:49
codcore

#TDD

refactoring code

before_action :find_question, only:[:show, :edit, :update, :destroy] before_action :find_question, except:[:new, :create, index]

this will call find_question action before all the other action

def before_action
@dohoonk
dohoonk / day20.md
Created February 6, 2016 00:37
codecore
  describe "#show" do
    it "finds the object by its id and sets to to @campaign variable" do
      # GIVEN:
      campaign = Campaign.create({name: "valid name",
                                  description: "valid description",
                                  goal: 100000})
      # WHEN:
      get :show, id: campaign.id
@dohoonk
dohoonk / day22.md
Last active February 10, 2016 23:24
codecore

ERD

One to Many

foreign key needs index contraint

bin/rails g model answer body:text question:references

@dohoonk
dohoonk / day23.md
Last active February 11, 2016 21:48
codecore

One to many

In the seed file ["Art, "Science", "Cats", "Sports", "Technology"].each do |cat| Category.create(name: cat) end

When trying to add category id

bin/rails g migration add_category_references_to_questions category:references

@dohoonk
dohoonk / day25.md
Last active February 19, 2016 20:16
codecore

#different users

make a relationship between user and the question

we need to add references

rails bin g migration add_user_references_to_questions user:references

bin/rake db:migrate