This week felt like a lot of new material at this stage. They warned us it's common for people to experience a dip in confidence around the halfway point in the course, and I can definitely relate to that, as I finished this week feeling pretty overwhelmed.
I think it's just that being expected to learn new stuff on a shaky foundation of existing knowledge feels difficult and a bit counterintuitive, but I'll talk about what we covered this week anyway.
We began on Monday with an RSpec recap and then a lecture about refactoring, with a view to making the code from our Rails projects from last week better. Something I hadn't realized before was that 'fat models and skinny controllers' is a convention that's considered good practice. This means that the business logic of an application should live in the model, leaving the corresponding controller with minimal code. I'd written the bulk of my logic in one controller, so I refactored my app to reflect this newly-learned convention. It's still not finished, but hopefully enough tiny steps will amount to something eventually!
Thursday we did pagination and infinite scroll, which was pretty cool as I'd always wondered how these worked. We used the will_paginate gem, but I think it'd be fun to try to figure out how this works in a more standalone way at some point.
Callbacks are hooks into the life cycle of an ActiveRecord object that allow you to trigger logic before or after an alteration of the object state. This can be used to make sure that associated and dependent objects are deleted when
destroyis called (by overwriting
before_destroy) or to massage attributes before they're validated (by overwriting
As I mentioned before, I feel like we touched on a lot of new, different things this week, so I need to spend some more time making sense of all this. But at least I have it in notes for future reference, even if I'm hazy on the details right now.