Thursday, February 27, 2014

First foray into Demigod code

During our team meeting on Sunday, I was put in charge of getting part of the user's profile page working. This included getting the profile picture display/upload capabilities working as well as putting in placeholders for user statistics. Since Fernando was responsible for the "current challenges" display (which will be included on both the profile page and the challenges page), he and I decided to work together because neither of us has had any experience with Rails prior to this project. We ended up meeting yesterday (Wednesday) for about four hours and were able to get the Paperclip gem (used for image saving and uploading) working after about an hour and a half working on it.

I have found that diving into the Demigod Rails code is certainly a change from tutorials, especially when you are trying to working around other components that were not present in the tutorials (such as registration). These difficulties are what caused some of our issues with getting Paperclip to work. For instance, we had to figure out which "edit" view to modify for the user (there were two, each of which was accessed by different links). Eventually, we are going to have to decide which of these to use (or how to combine them) since there should only be one edit page. Anyway, we were able to modify the user show view page to show the profile picture once the user had uploaded it and we were able to modify the user edit view page to include an upload button for uploading a profile image.

I added an additional feature this morning, which included displaying a "blank" avatar icon (i.e. the typical generic silhouette seen in place of a profile picture when you haven't yet uploaded one) when the user had not yet uploaded an image. I also set up a condition in the show view code that check if the user does not have a profile image and, if true, will make the blank icon into a link to the edit page where the user can upload an image. Actually getting the blank icon itself to display was a bit of a challenge because I had forgotten (though I know remember Matt mentioning it in his crash course) that Rails looks for assets (i.e. photos, CSS, etc.) in the "assets" folder and that you do not need to give Rails the path name, just the image name (as long as your image is stored in "assets/images"). After 30 minutes of frustration, I did some googling and went over my notes from Matt's crash course and discovered by error. Problem solved!

No comments:

Post a Comment