Homework for 13A

Review

Topics Covered: ActiveRecord Callbacks, ActionMailer

E1: Review

  1. What does a before_validation callback do?
  2. Does order matter in specifying callbacks?
  3. Give an example of when to use a callback
  4. Can Rails methods trigger callbacks? If yes, list a few.

E2: Meowbook wants to be bothersome

In today's code along, you learnt how to implement email functionality in an app. Kitties have been getting pretty frustrated with their inability to flood other kitty inboxes. For this exercise, implement the Action Mailer functionality to allow sending emails in your meowbook. For reference, use Action Mailer Rails Guide.

Note that we haven't told you exactly what you should be implementing in Meowbook with ActionMailer! It's up to you to decide how this feature could be used to make the project awesome! Note that it would be doubly awesome if you use ActiveRecord callbacks to accomplish this!

TA fun facts of the day!

Check these out:

  1. In Rails, if the last argument for a method is a hash, you can leave out the {}! This is especially common when the method has an options hash as its last argument, like the example below.
  2. Another fun fact is that you can use json-like syntax for ruby hashes like the example below. Please note that the key is still a symbol even though the colon follows the variable name.
  3. Hate putting in your username and password everytime you push or pull with GitHub? Set up your ssh keys here to skip these steps! Let a TA know if you run into issues doing this!
# The link_to method takes an options hash as its last argument
# so we can leave out the {} around class and btn
link_to "Edit", edit_tweet_path(tweet), :class => "btn"

# We could also use json-like syntax like so: 
link_to "Edit", edit_tweet_path(tweet), class: "btn"