- spoke about how to find out whether a class has a method. You can use .methods or .respond_to?('something') or .include?('something')
- learned about another form of looping: for … in. You can use it on any object that responds to each.
puts i
end
- learned about next and break. Next skips whatever comes after it and returns to the beginning of the loop. Break takes you straight down to the end and ends the loop.
- spoke about password protection. HTTP has a basic authentication which can be called in the controller of a Rails app and looks like this: http_basic_authenticate_with name: "rgsoc", password: "secret", except: :index .... this is, well, okay. But if your code is open source, you'll want some safer option because everyone can see your password on Github (or wherever you have your code). But given your app is deployed on Heroku, you could define a password there with heroku config:set NAME=rgsoc and heroku config:set PASSWORD=secret and then change the authentication on your controller to http_basic_authenticate_with name: ENV[’NAME’], password: ENV[‘PASSWORD’], except: :index if Rails.env.production?
- repetition on how to use the ternary operator. Good thing for refactoring. It's the same as if ... else ... end. This is how it looks like: condition ? true : false
- learned the last remaining Ruby keywords on our list: redo and not. Redo does the same action again. It's basically only useful when the output differs on repeating the action, e.g. when you create a random number. Not is the same as ! but the ! is safer to use. Just believe us.
- and last but not least we repeated all the keywords we've learned during the past almost 3 months. Somehow the lesson shortly drifted off to the fact that the Bible implies that PI is 3. Which led Erik to the conclusion: "Maybe God is just okay with rounding."