Whistle Sinatra App Process

By April 20, 2019 Uncategorized

Part of my reason for pursuing a career in web development was to create an app for reporting crimes. This project assignment was my first opportunity to attempt to create that app. This is all to say, I was more excited than ever to begin creating my very first web app using Sinatra. Through the process, I have learned a great deal, especially about the Google Maps Javascript API.

I began the process of creating the app with very big plans. I created 4 models, which I eventually slimmed down to just 2: user and report. When I first imagined the app I created models for a category object and a note object. The idea was that users could select or create categories for their reports so that the reports could be sortable and searchable by category. Additionally, users could comment on reports other than their own. For example, if there are other witnesses to the event that want to add information. I would like to add these features still, but in creating the app I was sobered by the sheer amount of time it takes to implement these features. I plan to continue working on this app in some form, even if it isn’t using Sinatra.

Part of the concept for the app is that the reports are created anonymously. Currently reports store the user id of the user who created them, which is not ideal. However, this does not compromise the anonymity of the app in any serious way. The user id is not displayed or accessible to the user. Even if a user had access to the user id they would need to connect that id to their username in order to identify the user who posted the report which is impossible. Furthermore, the app does not accept any identifying information on signup so the security risk is essentially nonexistent.

Another key feature of the app is for reports to be immutable, meaning no one can delete or edit the report once it is submitted. This feature requires the use of a blockchain, so it can’t be implemented using Sinatra. I hope in a further iteration of the app I can implement this feature.

The process of creating the app once I had tempered my plans was relatively straightforward. I used a ruby gem called corneal to generate a file structure for the MVC. Once the file structure was in place I edited the migration files, added the relationships to the objects, then set to work editing my views and routes. The user authentication methods are standard, I used helper methods #logged_in? and #current_user, but also created my own helper method #users_report? to check authentication on edit and delete requests. Because I had already worked on several similar apps using Sinatra, the process of creating this one was straightforward.

The app in its current state includes the following essential features: ability to create and login to user accounts, ability to create read update and delete reports, ability to visualize all reports on a map, and ability to view all reports or just a user’s own reports.  Features I would still like to add: immutability, true anonymity (user_ids are not associated with reports), notes for reports, categories, and the ability to search reports. There is only one bug that I am currently aware of which is that the report map will fail to load sometimes on the first time the page loads. I believe this has something to do with the initialization of the map. Thanks for reading and feel free to improve my code or test it out on your local machine! Here’s a link to the github.


Leave a Reply