Skip to content

Instantly share code, notes, and snippets.

@philsof
philsof / code-review-mirascarvalone-build-a-rails-blog.md
Last active February 10, 2016 21:47
Code review for branch mirascarvalone on challenge build-a-rails-blog 2/10/2016

This is good stuff, here are my notes on your code:

@philsof
philsof / code-review-for-branch-pair-silvestrijonathan-data-drill-stack-and-queue-challenge.md
Last active February 12, 2016 01:37
Code review for branch pair-silvestrijonathan on data-drill-stack-and-queue-challenge 2/11/16

Good stuff, here are my notes on your code:

  • You are getting this, good work! 👍

  • This test does the job. Be aware though: Rspec comes with built-in expect change test capabilities, which can test if an object changes. (For example, if the length of an array increased by 1.) This will come in handy in the very near future.

  • Note: You caught this error while I was writing this! Nice work! Here is what I wrote anyway:

This is a really tricky one to catch and is a good teaching moment: take a look at this test, which currently passes when it

@philsof
philsof / unique-constrait-on-active-record-migration.md
Last active February 11, 2016 20:53
How to implement a unique constrait in an Active Record migration

Here are the docs and here is a highly rated StackOverflow answer. (The docs are pretty long, you will probably want to search the web page for "unique" to find the relevant info.)

Bottom line: You need to create an index and make the index unique:

add_index :table_name, :column_name, :unique => true

Hope this helps. Any questions let me know.

@philsof
philsof / naming-conventions-for-a-many-to-many-table-and-model-in-rails.md
Last active May 12, 2022 14:37
Naming conventions for a many-to-many join table and model in rails

Migration table naming convention: groups_users

Migration file naming convention (the part of the file name that is not automatically generated): create_groups_users

Model class naming convention: GroupsUser

@philsof
philsof / useful-ruby-collection-methods.md
Last active January 29, 2018 02:17
Useful Ruby Collection Methods

Useful Enumerable methods (can be called on Hash objects and Array objects):

  • all?
  • any?
  • count
  • each_slice
  • each_with_index
  • each_with_object
  • find
  • find_all
  • find_index