App Academy: Week 8, Day 3
Today was the second day of capstone projects, and I'm still having a lot of fun with mine!
Building on yesterday's work, today I implemented a view for user profiles as well as the ability to create posts on them. This required adding a complete backend and for the posts resource, as well as writing several React components and a good amount of CSS to get the profile page to look like it should. In addition, I also started implementing Likes on posts, but still have some work to do on that.
One awesome thing that I learned today was that you don't always need a store or API util for every kind of resource that you have, even if you want to use it in some of your React components. For instance, in my app, users have posts attached to them (i.e. to their profiles) which in turn have likes attached to them. Thus, I want to display those likes within a component on those posts profile. Rather than making a whole other store and Flux flow to do this, I instead changed the ActiveRecord query in my API PostsController's index action to have .includes(:likes) added onto it. Then, I simply added a likes property to the JSON objects my controller serves back up to my frontend so that the posts objects had by my profile view also have those posts' likes attached to them. This way, getting the likes to display for a post is a sinch.
Tomorrow, it's on to implementing comments and (hopefully) friends!