Stuck on heroku setup page for ruby - ruby

https://devcenter.heroku.com/articles/getting-started-with-ruby#web-rb
I'm stuck at the "write your app" part. It gives a hello world example, so I tried doing that with vim:
The web.rb file reads as follows.
require 'sinatra'
get '/' do
"hello, world"
end
But, when I try and do: heroku addons:add newrelic:stark --app web.rb,
it says failed. app not found.
I'm probably missing something "obvious" because I've actually never worked with Heroku and hardly any Ruby before. Any help would be really appreciated.

If you're at "Write Your App", you haven't created a Heroku application yet, you've only just started writing the code for it.
Adding the newrelic add-on to a non-existent heroku app would likely give you that error.
Don't get ahead of yourself, finish the tutorial on creating the Heroku application before trying to add things to it.

Related

First Time Heroku Deploy App Can't Make Sense of Logs

This is my first time trying to deploy a small application on heroku to apply for an summer internship.
I went through the getting started guide with rails.
Here is my log, its just too much code
http://pastebin.com/QqaKVdH3
Is there something wrong with my rails app and not part of heroku?
Did I run out of dynos? I head into my apps, click on my app, and put in 2 dynos and 1 worker for my app.
I have this in my procfile, hopefully this is correct !
bundle exec unicorn -p $PORT -E $RACK_ENV
bundle exec rake jobs:work
sorry to bother you guys, I know I need to familiarize myself with the heroku docs but if someone know the answer to this, I would love the help! I will just dig into the heroku docs when I got the time.
If you need more information please let me know.
Thanks!
The error you should start with is this:
2013-05-13T19:35:12.367382+00:00 app[web.1]: E, [2013-05-13T19:35:12.367055 #137] ERROR -- : uninitialized constant SimpleForm (NameError)
After you get past that hurdle and any others, be sure to checkout the Dev Center guide on Unicorn:
Deploying Rails Applications With Unicorn

How to print debug messages with Sinatra/Foreman?

I'm just starting out with Ruby and with the sinatra framework. I've got a setup going now with heroku and I'm totally amazed how well it works. There is just one thing that I can't figure out. How do I debug stuff? Might sound weird but I have this variable that I'd like to print out and see, preferably in the terminal or something like that. How do I do this in ruby with forman running? When I write print or puts nothing shows upp in the foreman logging...
Thanks!
If you're using Foreman, try adding a log: process to your Procfile. For Rails apps, my Procfile looks like so:
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
log: tail -f -n 0 log/development.log
You'll want to configure Sinatra to log to a file, in my example log/development.log.
Locally, Foreman will automatically spin up a log process and spit the logs out to the terminal, similar to how what you see on Heroku. On Heroku, no log process will be ran unless you manually scale it (which you don't want anyway).

How to run my ruby file in heroku?

Sorry if i cannot make you understand, but this is how i understand and how i can tell you.
I am new to ruby and now i have learned a few and with that i have written a ruby code. It is actually to access the storageroom content management system from the form that i have done with ruby. And i used sinatra so i kept my stylesheet file in public folder and similarly i have a folder named storage_room_gem which i have to keep in the directory where my code is present.And another thing my code writes to a html file and it displays the html file.
Now i ran the code in my machine and it ran well. But i tried to run using heroku and it shows H10 error. what should i do?
By issuing the command
heroku logs --app <your appname here>
you can see the logs. The error should be listed there, as well as the stacktrace. If you post that, it makes it easier to help debug your code. Here is a link to more information on the heroku logs: https://devcenter.heroku.com/articles/logging#log_retrieval
Also, you can run it locally in a heroku-like environment using foreman. By running locally, you could have more tools at your disposal to investigate the error.
Here is a link to more information on foreman: https://devcenter.heroku.com/articles/procfile/#developing_locally_with_foreman

How to set framework id in a Heroku deployed Play! application

my question is simple. I want to set the play framework 'id' in my heroku deployed copy, different than the one I have locally.
To do so, I followed this reference page by running 'heroku run play id' from my local computer. However, that didn't work, as if I executed again the same command, it would tell me that the id was still empty.
So, I researched in StackOverflow a bit, and got to this page in which I understand, according to an answer, that I can do so by modifying the PLAY_OPTS variable, but I dont really get it... So if someone could explain it to me clearly, I would really appreciate it!
Thanks a lot in advance,
Pepillo
You can see the PLAY_OPTS environment variable with:
heroku config
Which should include:
PLAY_OPTS => --%prod -Dprecompiled=true
You can change that with something like:
heroku config:add PLAY_OPTS="--%foo -Dprecompiled=true"
But you will have to make sure that you also tell the Play app not to try and listen on the jpda port or it will fail to start on Heroku.
Edit your Heroku config (heroku config) and add PLAY_OPTS to your liking.
heroku config:add PLAY_OPTS="--%prod -Dprecompiled=true"
After, just change your Procfile to something like :
web: play run --http.port=$PORT $PLAY_OPTS

Heroku RACK_ENV says "development" on Thin, but "staging" on Unicorn

I came across this behavior and was wondering if anyone else had seen it. I have a workaround so it's not a show-stopper.
I created a new app on Heroku with a Cedar stack. When demonstrating multiple environments I added the following config var:
heroku config:add RACK_ENV=staging --app appname
I visually verified that the environment var was set, then put the following route in my simple Sinatra example:
get '/?' do
ENV['RACK_ENV']
end
When I tested locally on my laptop, I received the expected development.
When I pushed to Heroku and hit the same route on herokuapp.com I got development instead of staging.
I switched the web server from Thin to Unicorn through the Procfile and pushed the changes back up to Heroku.
Now when I hit the route, I get the expected staging.
Has anyone else seen this? My workaround on another project where I was running Thin was to key the environment off of the New Relic app name. (I didn't switch to Unicorn because I need New Relic to work and currently Cedar and New Relic and Unicorn work together).
I had the same problem with sinatra and thin on the cedar stack using heroku's example sinatra app. The RACK_ENV refuses to be set to anything but development. (Heroku seems to think that it's RACK_ENV is set, since running 'heroku config' displays the environment you set, however in the app it's always development).
The same app on the bamboo stack had no problems.
EDIT: I submitted a ticket to heroku about this and got a really quick response which fixed the bug for me:
QUOTE:
It looks like there's a small bug in our default Procfile if you're using thin. Can you create a Procfile with the following in it?
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
You can also set both your RACK_ENV and RAILS_ENV to staging using the Heroku gem ... then it works as expected. I think it may be a problem with Heroku.

Resources