Sinatra Project Flatiron Phase 2
For my Module 2 project I designed a CRUD MVC app using Sinatra. My app was designed to allow users to write any article of their choosing, and to contribute it to the main page for all other users to view.
In comparison to Module 1 CLI, I found this project to be much more involved in terms of the number of different aspects to do with the framework. Though the logic itself was fairly straightforward (i.e HTTP requests), there was a far greater amount of building required, and more ground to cover in general. It was exciting to know as I worked on this, that this serves as the basis for building with Rails.
The first issue I encountered building this project was the sequence of my routes. I spent far too long trying to figure out why my site was returning “NO GET DATA/NO POST DATA” to perfectly valid(I thought) routes that I had written. When I went back to a lecture video and heard a brief mention as to the importance of route sequence, I felt like the sky had opened. A couple of switch arounds and lo and behold, my first few article routes worked! With that said, I had to change order almost every time that I implemented a new route within the controller.
Learning how to use embedded Ruby code within views was a challenge, particularly figuring out how to link the user to the appropriate routes for CRUD actions within index.erb.
Learning how to use Tux for CRUD and associations was a fun experience. It was interesting to watch ActiveRecord firing automated SQL in the terminal.
I was grateful that even though this project had a few different bells and whistles to address, that the MVC relationship itself was fairly straightforward and easy to grasp. Another issue that I encountered, and am continuing to learn the importance of, was validations. I spent almost a day trying to figure out why my page was not rendering, to find out about the importance of the has_secure_password’s partner, the password_digest attribute(which I was missing from my schema). This is a B-Crypt method for password authentication.
Learning all of this information and how it all related to each other was definitely challenging. As I stated in the beginning, the sheer amount of knowledge to learn and to become familiar with was daunting, but rewarding in every small victory. Upon the completion of this project I am excited to move forward into working with Rails in Module 3.