Ruby Sinatra Flatiron Project

Rony M.
2 min readJan 7, 2021

After a long while grasping Ruby’s Object Oriented on the first boot camp project, I moved forward to real web apps that renders on the browser, instead of our local terminal.

Sinatra is a Ruby web framework which, when generated through the Corneal gem, offers a pre-built MVC structure for easily organizing our files, their responsibilities and interactions among each other.

For this session, my application (Tasker) is a tasks tracker for registered users (or a to-do list as you might wish), which I believe is a great option for beginners who are getting into the CRUD functionalities and ActiveRecord database generators.

During the progress, I also learn about ERB templating, which is Ruby syntax combined with HTML tags. That brings us to that old good practice known as DRY (Don’t Repeat Yourself), keeping our files more readable and less redundant with the help of the “yield” keyword, which allows us to re-render the desired views anywhere else in our files, just like a global variable.

On this project I can also explore my design creativity by using CSS, alternatively with a framework of preference if desired, such as Bootstrap, Tailwind or Bulma. I could also have used something more robust, like a JS library or framework, which would also turn it into an SPA (Single Page Application). But instead, I opted for keeping it simple for a Sinatra app and save them for the next projects.

In the main app folder, under the same name, is where the MVC folders and files are structured. The model classes being only 2 files (for task and user), 3 view files for users/tasks each (along with the home and layout files), and finally 3 controller files for requests from the models.

Working with routing was fun, almost like playing puzzles. I also found the ActiveRecord functionalities very interesting for how easy it made me manipulate databases in real time, without having to do it manually like would be the case using MySQL or older languages.

Here’s the project’s repository: https://github.com/Roeck/Tasker.

--

--