This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandyJar < ActiveRecord::Base | |
has_many :candies | |
accepts_nested_attributes_for :candies, :reject_if => lambda { |a| a[:pricing_type_id].blank? }, :allow_destroy => true | |
#custom validators for nested attributes arrays | |
validate :has_candy #returns true if at least one candy attribute is passed | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :candy do | |
candy_jar #name the association | |
user_id 1 | |
description { Faker::Lorem.paragraph 4 } | |
rating 1 | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :candy_jar do | |
user_id 1 | |
description { Faker::Lorem.paragraph 4 } | |
rating 0 | |
before(:create) { |candy_jar| | |
candy_jar.candies.build( [FactoryGirl.attributes_for( :candies )] ) | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.create(:candy_jar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Screen Casts: | |
- part 1: intro to events: https://youtu.be/1rKKtzKE01g | |
- part 2: using events in tic tac toe:https://www.youtube.com/watch?v=dYaHRkC3IbY | |
### Notes: | |
https://github.com/ga-students/WDI_skywalker/blob/master/w02/d02/INSTRUCTOR/events.md | |
### Questions: (please write out your answers) | |
- what is an event? | |
- why does an event happen? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
font-family: sans-serif; | |
} | |
body { | |
margin: 0; | |
} | |
h1{ | |
margin-top:30px; | |
text-align:center; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link href="styles.css" rel="stylesheet"> | |
</head> | |
<body> | |
<h1>tic tac toe</h1> | |
<div id="board"> | |
<div><button id="a1" class="cell">x</button><button id="a2" class="cell">o</button><button id="a3" class="cell">x</button></div> | |
<div><button id="b1" class="cell">x</button><button id="b2" class="cell">x</button><button id="b3" class="cell">o</button></div> | |
<div><button id="c1" class="cell">x</button><button id="c2" class="cell">o</button><button id="c3" class="cell">o</button></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//If these DOM elements don't exist yet, just create them!!!!! | |
// 1 | |
var h3 = document.querySelector('h3'); | |
// 2 | |
var h3 = document.querySelector('h3'); | |
h3.innerText = "Monkey Cheese"; | |
// 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Welcome | |
--- | |
## Sinatra | |
--- | |
### After this you will be able to: | |
- make an instance of a web server and have it serve content to a user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## User Auth Rails app: What we're adding: | |
- User model | |
```bash | |
rails g model user username:string password_hash:string | |
``` | |
- user_id foreign key in tables (user has many cars) | |
generate a migration | |
```bash | |
rails generate migration addUserId |
OlderNewer