loading...

Getting Started in Sinatra with Corneal

mariel profile image mariel ・2 min read

Alright, this week's post is a 30 second rundown of something I spent an hour looking for earlier this week. Now it'll be saved in one spot for me AND for you.

What is Sinatra?

Sinatra is a Ruby gem that lets you "quickly creat[e] web applications in Ruby with minimal effort."

That minimal effort does come at a cost - because Sinatra is so lightweight, you're not getting as much built-in upfront as you do with a full framework like Rails. You're responsible for pretty much everything - app structure, generating files and directories, etc.

So, why Sinatra?

In my bootcamp, we used Sinatra before we got to Rails so we'd be required to learn the concepts behind Rails before just booting up rails and poof! having things working.

We used Sinatra in conjunction with learning about MVC architecture, setting up routes, and making all the different pieces talk to each other. It definitely provided a good foundation and made Rails easier to pickup and easier to like.

What's Corneal, then?

Corneal is a beautiful little gem created by a former Flatiron student named Brian Emory. Avi suggested he "maybe build a CLI gem that generates our sinatra structure using some sort of ruby templating gem . . . ."

So, he did.

Once Corneal is installed, you can get up and up and running with three commands.

gem install corneal
corneal new MY-NEW-APP-NAME
bundle
Enter fullscreen mode Exit fullscreen mode

THAT'S IT. THAT'S THE TWEET.

Wait. What?

That's it. With those three lines you'll get this:

└─app
  ├── controllers
  │   ├──application_controller.rb
  │   └──new_model_controller.rb
  ├── models
  │   └──new_model.rb
  └── views
      ├──new_models
      │  ├──index.html.rb.erb
      │  ├──show.html.rb.erb
      │  ├──new.html.rb.erb
      │  └──edit.html.rb.erb
      ├── layout.erb
      └── welcome.erb
Enter fullscreen mode Exit fullscreen mode

I KNOW. SO MUCH TIME SAVED.

Okay now what?

From there, you can edit and add as needed - add your various views, models, get your schema set up, get your controllers working. You'll still have to build a lot yourself, but having the scaffold just makes it easier on the brain to get going.

Have fun out there.

go forth and dazzle

Posted on by:

mariel profile

mariel

@mariel

Junior Dev. I love dogs, cookies, and learning new things.

Discussion

pic
Editor guide