Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Kian Chakamian
Kian Chakamian
15,410 Points

How can I Make My Sinatra App Public?

I have a completed my Sinatra app and I now want to make it public so that everyone can see it. I have no clue where to start or what to do.

Sandra Hogan
Sandra Hogan
8,657 Points

You can deploy your app to Heroku. You can find Instructions for deploying a Sinatra app to Heroku here.

Kian Chakamian
Kian Chakamian
15,410 Points

I just tried following the instructions on the page you provided and I couldn't get the step: "git push heroku master" to work. It just gave me errors that I don't know how to fix. Is there any other ways to make the website public.

4 Answers

Sandra Hogan
Sandra Hogan
8,657 Points

A Gemfile is a file that you create which is used for describing gem dependencies (or which gems your program needs in order to run successfully) for Ruby programs. A gem is a collection or snippet of Ruby code that adds functionality to your program.

At the very least your Gemfile should contain something like this:

# define our source to look for gems
source "http://rubygems.org/"

# declare the sinatra dependency
gem "sinatra" 

If you happened to use Bootstrap to style your app you would include gem 'bootstrap' in your Gemfile after the Sinatra gem....as well as any other gems you might have added to your program.

Then after creating a Gemfile you will need to run bundle install which will install all the gems you have listed for your program. If your Gemfile is correct you probably wouldn't normally need to manually create a buildpack...but I don't think it will hurt anything if you now add your Gemfile.

Kian Chakamian
Kian Chakamian
15,410 Points

After adding a Gemfile it worked! Thanks for all your help.

Sandra Hogan
Sandra Hogan
8,657 Points

Yay! Glad it worked! Do we get to checkout your app??

Sandra Hogan
Sandra Hogan
8,657 Points

There are other services such as Digital Ocean and Amazon and maybe others but not sure how they work. You can probably find information about each on their websites.

You could also share you error messages and maybe someone can help you get up and running with Heroku.

Kian Chakamian
Kian Chakamian
15,410 Points

Here is a copy of my error message:

Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (18/18), 2.81 KiB | 0 bytes/s, done.
Total 18 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     No default language could be detected for this app.
remote:                         HINT: This occurs when Heroku cannot detect the buildpack to use for this applicat
ion automatically.
remote:                         See https://devcenter.heroku.com/articles/buildpacks
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to warm-stream-94858.
remote:
To https://git.heroku.com/warm-stream-94858.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/warm-stream-94858.git'

My config.ru was the same as the one provided I replaced the hello.rb with my Sinatra file name.

Sandra Hogan
Sandra Hogan
8,657 Points

I am not entirely sure without seeing your code but you might want to make sure your gemfile is present. But maybe also try manually configuring the buildpack by checking out https://devcenter.heroku.com/articles/buildpacks

Kian Chakamian
Kian Chakamian
15,410 Points

Ok, I set a buildpack for ruby and it said it was setup. Then I tried to push to heroku and it gave me a diffrent meessage:

Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (18/18), 2.81 KiB | 0 bytes/s, done.
Total 18 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby
.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to warm-stream-94858.
remote:
To https://git.heroku.com/warm-stream-94858.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/warm-stream-94858.git'

I went to the page with more info in the error message and it told me that I needed a Gemfile which is also what you said. I do not have a good understanding of what a Gemfile is or how to set one up. All I understand is that it tells the app reads the Gemfile to understand what gems are present in the rest of the app. I currently do not have a Gemfile in my app. Could you tell me how to set one up? I am using ruby version 2.3.1, Sinatra version 2.0.0 and URI.