Creating a Student Directory
For my Rails Assessment I had been dabbling with the idea of learning and the process we go through as we acquire new skills working on lessons and projects here at Learn. However when it came down to finalizing a project I had tried repeatedly to see what other people had done for inspiration. It turns out however that this was something that was easier in theory than in practice. If I wanted to check out what someone had done I had to go to their GitHub profile and try to track down the correct repo. While the act of browsing a specific repo isn’t difficult, tracking down the the right one can be. Most people are more creative than `“Unit-name”-assessment` when it comes to naming their projects. And so in the spirit of FOSS and entrepreneurship I decided to make it myself.
Realistically what I’ve created could be used for nearly any community that wanted to create a simple directory. The idea was to create something more akin to a template and add in some basic styling that would make it extensible to Learn. By using a color picker and grabbing some images from Learn’s website I managed to style my project using an almost identical color palate to what Learn is currently using. (other than one shade of purple I tweaked it’s a perfect match) If they wanted to it would be a “relatively” simple addition to add it into the website *wink wink cough cough*
Modeling the directory was something I’ve written about earlier and even changed again. Initially I believed I focused to much on making my DRY at the expense of its “Rails-y-ness.” While it created headaches refactoring almost everything, it was a great learning experience seeing what Rails did for me by convention compared my hacked together Frankenstein code base. Several revisions later convention carried the day and my directory followed a far more typical Rails pattern.
For the design I really wanted to look outside of bootstrap and explore other frameworks. While Bootstrap is what Learn teaches and is maybe the most well known CSS framework, I wanted to try something else and see how they compared. Ultimately I settled on the Foundation framework; it also had a grid system and shiny new release so I figured it wouldn’t be to difficult to pick up. With plenty of documentation and a few templates that were fairly close to my mockups I decided to give it a chance. Once I learned Foundation’s grid system it was a fairly easy switch.
Functionally I decided to incorporate Devise and Omniauth for GitHub to handle users. Given that Learn already used the same approach I felt that this was all but decided for me when I decided on the project. Wiring Devise may be complicated but because its so widely used there is a plethora of documentation. One thing I did discover however is that it is very difficult to find help with errors relating to setting up GitHub with Omniauth. While setting up the GitHub callback path I encountered an error that seemed to baffle everyone who tried to find the root cause. Searching for help regarding GitHub’s implementation of Omniauth was difficult because most issues, no matter their relation to GitHub’s Omniauth, are hosted on GitHub itself! Even most of those that are not commonly reference Omniauth itself since it’s hosted on GitHub. This made finding others who encountered issues far more tedious than say searching for Facebook Omniauth errors. Eventually persistence paid off and the offending issue was located and fixed to much rejoicing.
The last part of my project was handling authorization. While it may have been a little overkill for a solution I wanted to implement CanCan, mostly because I was having trouble understanding it from our lessons. I wanted to keep three distinct levels of authorization; a guest who could read anything, a user who can edit their profile and assessments, and an administrator who would have full access. Handling admins and guest worked fairly straightforward. If they had an admin boolean of ‘true’ they could TGM to their hearts content. Similarly if “current_user” was checked with an ID of ‘nil’ it was easy to set a guests authorization (or lack of authorization rather). Setting an ability for ‘current_user’ proved to be a great way to learn about how CanCan practically and apply it even if it took a few attempts to get the model right.
After much revision my student directory is finally in a quasi finished state. As it exists currently it would be a usable for nearly any organization to use as a template that they could tweak subtly to suit their style quickly. In the future I plan on making a few additional changes to add the ability to post screen shots and make the search bar functional. For now however feel free to check out the code here!