<commit_before>---
layout: default
---

## Wk3 - Wednesday - ActiveRecord and Unit Testing

**Challenge:** [Arrays and Hashes](https://github.com/masonfmatthews/rails_assignments/blob/master/challenges/array_and_hash_challenge.rb) (this builds on yesterday's challenge, so bring this code up and use it: [Yesterday's Solution](../2/challenge.rb))

**Problem of the Day:** [Phone Numbers Active Record](https://github.com/masonfmatthews/rails_assignments/blob/master/exercises/phone_numbers_active_record)

* Agile Principles
  * Immerse yourself in the culture.
  * Read some every day.
  * Ruby Rogues and Ruby Weekly.
  * Dissecting a book vs drinking from a fire hydrant.
  * DIAGRAM: Developer spectrum.  Hammer-user all the way to shiny-object.
  * ON BOARD: Balance hammmer-user and shiny-object.
  * ON BOARD: All code becomes legacy code.
  * Arguably, worked on some last night.
  * Definitely working on some this weekend.
* ActiveRecord Models
  * Using `irb` accesses the same database as `ruby ...`
  * `.new`
  * `.save`
  * `.create`
  * `.update`
  * `.all`
  * `.first`
  * `.find` and `.find_by_id`
  * `.find_by_name`
* Relations
  * `.where`
  * `.order`
  * `.count`
* Basic Associations
  * `has_many`
  * `belongs_to`
* Unit Testing
  * Test database vs development database
  * `def setup` and `def teardown` (for migrations)

#### Lecture Notes/Links

* [Class Video]()
* [Whiteboard - ActiveRecord's Commands](http://tiyd-rails.s3.amazonaws.com/pictures/uploaded_files/000/000/032/original/db_migrations.jpg?1442425662)
* [In-class ActiveRecord code](https://github.com/tiyd-rails-2016-01/first_active_record)

#### Useful Links

* [Ruby Weekly](http://rubyweekly.com/)
* [Ruby Rogues](http://devchat.tv/ruby-rogues/)
* [Most common jobs in america](http://www.npr.org/blogs/money/2015/02/05/382664837/map-the-most-common-job-in-every-state)

#### Evening Reading

* Preview Reading: [Pro Git Ch. 2.3](http://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History)
* Preview Reading: [Pro Git Ch. 2.4](http://git-scm.com/book/en/v2/Git-Basics-Undoing-Things)
* Preview Reading: [Pro Git Ch. 3.1](http://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell)
* Preview Reading: [Pro Git Ch. 3.2](http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
* Listening: [Ruby Rogues - Code Reading](https://devchat.tv/ruby-rogues/031-rr-code-reading)

#### Assignment
<commit_msg>Add HW for week 3 Wednesday.<commit_after>---
layout: default
---

## Wk3 - Wednesday - ActiveRecord and Unit Testing

**Challenge:** [Arrays and Hashes](https://github.com/masonfmatthews/rails_assignments/blob/master/challenges/array_and_hash_challenge.rb) (this builds on yesterday's challenge, so bring this code up and use it: [Yesterday's Solution](../2/challenge.rb))

**Problem of the Day:** [Phone Numbers Active Record](https://github.com/masonfmatthews/rails_assignments/blob/master/exercises/phone_numbers_active_record)

* Agile Principles
  * Immerse yourself in the culture.
  * Read some every day.
  * Ruby Rogues and Ruby Weekly.
  * Dissecting a book vs drinking from a fire hydrant.
  * DIAGRAM: Developer spectrum.  Hammer-user all the way to shiny-object.
  * ON BOARD: Balance hammmer-user and shiny-object.
  * ON BOARD: All code becomes legacy code.
  * Arguably, worked on some last night.
  * Definitely working on some this weekend.
* ActiveRecord Models
  * Using `irb` accesses the same database as `ruby ...`
  * `.new`
  * `.save`
  * `.create`
  * `.update`
  * `.all`
  * `.first`
  * `.find` and `.find_by_id`
  * `.find_by_name`
* Relations
  * `.where`
  * `.order`
  * `.count`
* Basic Associations
  * `has_many`
  * `belongs_to`
* Unit Testing
  * Test database vs development database
  * `def setup` and `def teardown` (for migrations)

#### Lecture Notes/Links

<!--
* [Class Video]()
* [Whiteboard - ActiveRecord's Commands](http://tiyd-rails.s3.amazonaws.com/pictures/uploaded_files/000/000/032/original/db_migrations.jpg?1442425662)
* [In-class ActiveRecord code](https://github.com/tiyd-rails-2016-01/first_active_record)
-->

#### Useful Links

* [Ruby Weekly](http://rubyweekly.com/)
* [Ruby Rogues](http://devchat.tv/ruby-rogues/)
* [Most common jobs in america](http://www.npr.org/blogs/money/2015/02/05/382664837/map-the-most-common-job-in-every-state)

#### Evening Reading

* Preview Reading: [Pro Git Ch. 2.3](http://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History)
* Preview Reading: [Pro Git Ch. 2.4](http://git-scm.com/book/en/v2/Git-Basics-Undoing-Things)
* Preview Reading: [Pro Git Ch. 3.1](http://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell)
* Preview Reading: [Pro Git Ch. 3.2](http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging)
* Listening: [Ruby Rogues - Code Reading](https://devchat.tv/ruby-rogues/031-rr-code-reading)

#### Assignment

{'fraction_non_alphanumeric': 0.15649324047521507, 'fraction_numerical': 0.024784924211388774, 'mean_word_length': 3.9573604060913707, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5684143', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1759, 'n_words': 385}