99cats

Jun 05, 2013

App Academy W4D3

99 Cats

Today we spent our time working on an extensive rails app for the first time, taking in all parts of the MVC framework and making it work together to do something pretty awesome. Our project was to create something called 99 cats, which is a knockoff of 99dresses in that someone can go rent out a cat for a certain period of time. We had to create a system that kept track of cats, assign them to a certain user and present all the user interface needed to make that cat rental possible. Not only that, we had to layer on certain now-to-be-expected features like user authentication and authorizationn. This means that only admins can have certain features and have access to certain parts of the system.

Right off the bat this seemingly simple implementation came across some issues. For one thing we had only one day to do the whole thing. Some of the stuff that we learned yesterday we had to apply and then add. We added a password hash to the users table so that we never store the passwords plaintext in the database. I did not do that in the previous day’s project. We implemented a session hash where the rails app could actually set the cookies in the browser. Now that someone logs in and then navigate the rest of the simple site without having to continually put in their password and credentials.

Let us start with the data layer. There were only three models. The user, the cat, and the cat reservation. Cats own a cat reservation and a user owns a cat. Not sure how that one works but we can talk about that later. A user can go to a “cat profile’ page and see all the reservations listed under that particular cat. The page is able to render however many reservations that the cat might have. Not only that we spent time creating a custom validation where the cat can be looked at by the rails app and any reservation that does not fall under certain guidelines (like the end or start dates are off whack or conflict with an existing approved reservation) would be rejected. Then you can navigate to another page and create reservations. We wrote logic that says that if a cat has been reserved for a period of time then all the other unapproved reservations under that cat during that time period would fall “disabled’.

We built out those core features first. Then we had to create a sessions controller in Rails that would create and store a “current user’ variable. This current user would be derived from the cookies inside the browser. I expect that later on we would be able to add more things like an admin function and what not. It was in the end pretty awesome. I certainly wish that I could have spent another day or two to tighten things up. There are still a lot of things that I wish I could create. For example, while the authentication - proving to the app that you are someone who has signed up in the app - was built out the authorization - the part with the admin roles and making sure that a user cannot mess with things he is not supposed to mess with - is still sorely lacking. However AA does not wait for anyone. We move on to a whole new app tomorrow.

I am writing this on the caltrain back home and am exhausted but I feel glad that I went through and created.