Sinatra Project
As the new year begins, another project ends. For my second project, I was assigned the task of creating an MVC app with Sinatra. This app is all about movies and movie reviews. The user can create an account, read reviews posted by other users on what they thought of certain movies and even create their own. They can also edit or delete their posts but not those that belong to other users. This function is known as CRUD (Create, Read, Update, and Destroy). I also have a page that users can add movies and their descriptions.
Compared to the CLI project, this one proved to be a bit more challenging but enjoyable. If there is one thing I will say to take away from it, it would be this: properly close your end tags! There were numerous times when working on my app that I would have a page crash and I would need to scan up and down to identify the cause, only to find outlater on that I was missing “<%” at one or two tags. I cannot stress how useful rereading your code is, even the end tags.
Requirement Breakdown
Although there was some freedom to this project, there were some goals we were meant to complete. One of the goals was to have multiple models.
For my app, I of course had to have users. Along with that, I wanted a page for the user to have access to information about movies and reviews to those movies. These models had to have at least one “has_many” relationship and one “belongs_to” relationship, which you will see below.
Our app is also required to give the option to the user to make an account, log in, and log out. When creating the account, the app has to verify the creditentials and ensure that the new account has a unique username.
Finally, the app assigns certain conditions to the user and accepts information only good data. The user is allowed to create, edit, and delete their own submissions, but not if it does not belong to them. Since I have two different models that belong to User, the restrictions are not the same. For reviews, a user has the usual permissions; to create, edit, and delete only their own, but for the movies this is different. When submitting a movie, the information can be edited by any user. Along with that, both models require to have complete information and displays an error message in the case of missing information, or “bad data”.
With my project finally complete, a new module begins. Even though it took me longer than I anticipated, creating this app has helped me better understand the use of controllers, models, and working with databases.