Building MVC Sinatra Project(Golf Group Finder)
I can’t believe that this blog posting is for second project already.
this time I have built Web App using Sinatra.
Sinatra is a framework written in the Ruby language. It’s designed as a simple, but powerful and flexible way to build web-delivered application without too much setup, configuration. It is considered a light weight framework.
Sinatra allows you to use concepts of MVC.
M- Model
V- View
C- Controller
MVC is a software design pattern commonly used for developing user interfaces that divides the related program logic into three interconnected elements.(Wikipedia)
The Sinatra DSL(Domain Specific Language)
Any Application that requires the Sinatra library will get access to methods like get and post. these methods provides the ability to instantly transform a Ruby application into an application that can respond to HTTP requests. (learn.co lesson)
my application is called Golf Group Finder. the purpose of this app is to make user to find people who play golf together.

my app has two Models User and Schedule.
and has three views folders. users, schedules, and errors.
each view folder has some erb files. These erb files is the HTML that we want our users to see.
and has two controllers. application controller and schedule controller.
A route is a The HTTP method paired with a URL-matching pattern. Each route is associated with a block. The matching route defined in the controller would look like this

Users can upload their golf schedule(ex. tee time) and it will be listed on schedule page. and other users are able to see that lists so that they can find golf schedule that fit their time.

and controller has CRUD and REST.
Create- is for creating a new resource that would be stored in the database
Create Route:
GET/schedules/new
POST/schedule
Read- reading information from your database in the browser.(list or more information)
Read Route:
GET / schedules
GET /schedules/:id
Update- is when we want to update a resource, for example we made a typo and want to correct it.(edit, update)
Update Route:
GET /schedules/:id/edit
PATCH/schedules/:id
Delete- Deleting a resource.
DELETE/schedules/:id
below picture shows some routes in my code.
also I have Helper class including two methods.
current_user and is_logged_in? these helper method make it cleaner to add logic to our views.

so far, I was only user that using App that someone else built. and I had no deep understanding how it works.
This Sinatra project was so helpful to understand how app works. not only front-end but also back-end.
I will update more and keep adding some features or edit some features on this.
thank you for reading.