The hardest part about a new project, language or framework like Sinatra is how to get started setting it up. Let’s go over the steps together.
-
Save yourself sometime and install the Corneal Gem created by former FlatIron Student Brian Emery after he had become a developer - gem install corneal.
-
Type corneal new “insert project name here no quotes” into the cli and hit enter.
-
Create your git hub repo and set up your project to be able to push.
-
Bundle install.
-
Check to see if everything is working by running shotgun.
-
Create the rake file and add the task for console pry. This will help you later on.
-
Add your models. For this FlatIron Sinatra project, at the time of this writing, it will only require 2 to meet the MVP. Steer away from has many through options unless you are up to the challenge. How difficult were the previous lessons for you to get through?
-
Run rake db:create_migration NAME=create_users and again for whatever the “belongs to” object will be. Make the table name plural so your model name is singular.
-
Fill out your table data with attributes make sure to give your “belongs to“ object a user_id column in the table - this is the foreign key.
-
Run rake db:migrate
-
Create a db:seeds.rb file and use the faker gem instead of manually creating data so you get moving faster.
-
Run rake:db:seed with your data so you can test your models, session etc.
- Make sure you enable:sessions in the application_controller.rb file as well as set your session_secret, this is done manually ONLY for this test project. It should never be manually created – period for security use a generator.
- In the config rackup file add - use Rack::MethodOverride and make sure to use your non ApplicationController. ONLY the application controller should be run. Secondary and tertiary controllers are placed above the application controller and have a command of use.
You should be ready to rock. There is a lot of work ahead, but you should be able to get going without many errors.