Heroku is driving me nuts! Is my code amazingly sloppy, or is Heroku amazingly picky? - ruby-on-rails-3

wow. going super nuts here trying to deploy to staging on heroku cedar from Rails 3.2.2. I've gotten everything to work, but I wanted to run these issues up the flagpole to see if there's something wrong with... me. eheh
Both of these issues give me the not-helpful "We're sorry, but something went wrong." error page. So it was frustrating when I had 2 different issues (that acted like 3) in one deploy (that worked fine on my local).
Heroku won't give me my logs.
when I run
heroku logs
I get a long error message that starts with,
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Permission denied - connect(2) (Errno::EACCES)
so i've been doing all this troubleshooting via small slices of commits. maddening.
Heroku chokes when it can't find an image with image_tag
this works on heroku:
= image_tag("content/portfolio/maskphoto_rubble_rebel_blur.jpg", :alt => params[:photo], :width => "100%")
This doesn't (only difference is an extra letter in the file name, though it works on my local):
= image_tag("content/portfolio/maskphoto_rubble_rebell_blur.jpg", :alt => params[:photo], :width => "100%")
Am i nuts in thinking that heroku should just serve up the image tag as-is and let it just not display, rather than crashing the entire page? I'm running compass; not sure if that has anything to do with anything.
Heroku hates nested expressions in an array ref
this works:
n = f.index(params[:photo]) +1
#nextphoto = f[ n ]
this doesn't (but does on my local):
#nextphoto = f[ f.index(params[:photo]) +1 ]
i guess it's better form to separate expressions, but still. why would it work on my local and not on deploy?

I can't directly answer all of your questions, but here are a few things to look at:
Heroku won't give me my logs.
The error you are getting indicates Permission denied ... Perhaps your account credentials are not setup properly? I see you are on a windows box ... on a unix machine, the heroku client writes a file at ~/.heroku/credentials with the username and what appears to be an API token. Check to see if you have a similar file. You can also check https://toolbelt.herokuapp.com/windows and make sure you have successfully performed the heroku login command.
Heroku chokes when it can't find an image with image_tag
I don't have many ideas here. Perhaps it is related to the asset-pipeline?
Heroku hates nested expressions in an array ref
This one doesn't make a whole lot of sense either. Perhaps the logs can shed some light here. I did notice that you appear to be running Ruby 1.9.3 on your system, and I don't believe heroku supports 1.9.3 yet. Maybe you have hit a version-specific bug.
I hope that helps. Good luck.

Related

Heroku: http-error 410. Invalid response from API (I am not behind a proxy)

I am currently having some issues with heroku. I just installed it and tried to heroku create. It takes my credentials but so far i just get this
! HTTP Error: https://api.heroku.com/login 410 Gone
! Invalid response from API.
! HTTP 410
! {myMail myPw}
!
! Are you behind a proxy?
! https://devcenter.heroku.com/articles/using-the-cli#using-an-http-proxy
I have been looking around for others with that issue but they all were behind a proxy. I am not. I also checked my firewall settings and also tried to run the command line client with admin rights. But nothing has proven to be successful so far. I'll keep trying and post an answer as soon as i figure it out. Maybe someone of you has an idea. Would be appreciated. Thanks in advance and
Greetings Chris
EDIT
Maybe some info. I'm running
Windows 10 Pro (V10.0.15063)
and a basic network setup with a router and DHCP
I had the same problem today.
When I type
heroku
in my Command Prompt, it promotes me to enter my email and after that my password. Then I got the same error message as you.
After that instead "heroku" I typed
heroku login
I entered the same email and password and everything was fine.
Ok. I made it work. Unfortunately I'm not really understanding why this worked which is pretty unsatisfying but I'll tell you what I did. I stumbled on some posts that were saying heroku-cli is outdated if that happens. First I tried to update it with npm using
npm update -g heroku-cli
which basically made heroku stop working alltogether because now the cli reported it needed node >7.X (and I was still running on 6.X). The node update I then made also didn't help because now heroku-cli was unable find the command bash.
In the end I just reinstalled heroku. After that (with at first getting the same error as in the beginning) I first did
heroku update
and after that heroku login worked. Now why I don't really grasp and maybe someone of you guys knows. But the version I had before heroku update was exaclty the same as afterwards
heroku-cli/5.11.12-8ae9780 (windows-amd64) go1.7.5
I found out the heroku.cl was blocked by my antivirus and unblocked it. Now its working flawless.
Updating Heroku worked for me.
heroku update

A custom route is matched in development but results in 404, in production

I have a following definition in my routes.rb
match "/block/:name/:action" => proc { |env|
#heavy magic happens here
}
I use it for handling rendering of cells. My problem is that the following link:
/block/reporting%2Fother%2Fexample/new?exampleable_id=23736&exampleable_type=Abc%3A%3ASomeType
works perfectly fine in development mode, but in production I get "404 Not Found". The only difference between production and development urls is that the one in development uses http and the one in production uses https. I would understand if I wrote a faulty code my proc block, but for the love of god I can't understand why it is not matched in production environment, when it works perfectly fine in development.
Any hint on how to debug this is highly appreciated. There is not so much hair left on my head.
I got this error even when if I finally launched the project in production environment on my local machine. The thing is we do not use Thin in production. We use passenger. After I finally got passenger working locally, I managed to recreate the error.
It turned out that with passenger, the :name in aforementioned route wasn't interpreted as "reporting%2Fother%2Fexample", but possibly as /block/reporting/other/example/new" with the rest not matched, of course.
I fixed the error by replacing
match "/block/:name/:action"
to
match "/block/*name/:action"
I hope this answer to my own question helps someone in the future.

Rails server log not outputting immediately

We use Foreman to start all of our web processes in development.
A while back, I tried to get the ruby-debugger gem working with this setup, but I couldn't, so I abandoned my effort. Along the way, I must have changed some setting or another, and now when I try to look at the server log in real time when I make a request to my local environment, nothing gets printed out. I have to kill foreman in order to see any output from the request.
This is really slowing down my development, as I have to make a request, kill foreman to get information about what went wrong, then start up and try again.
Any ideas how to get my server log to spit out everything as I'm making requests?
I had the same problem. It's solved here:
It's as simple as adding a line
$stdout.sync = true
To your config/environments/development.rb file, then restarting foreman.
Worked for me and makes my life much easier.

Panda gem and heroku

I've tried following the instructions here:
http://devcenter.heroku.com/articles/pandastream
However, when I open up the heroku console and run the command:
video = Panda::Video.create(:source_url => "http://panda-test-harness-videos.s3.amazonaws.com/panda.mp4")
I've tried adding lots of dynos with:
heroku dynos 100
However I still get the following error from Heroku:
Your application is too busy to open a console session.
Console sessions require an open dyno to use for execution.
Where could I be going wrong?
Cheers,
Richard
That seems more like a problem with Heroku not having setup your app yet, or some other underlying problem.
I have no trouble with this, so write them, and ask what's up :)

Debugging admin_data in Heroku

I'm new to rails and ruby and was able to stitch together my first app and launch it on heroku. All is well, and now I'm trying to solve the problem of how to manage my data. I found the plugin called "admin_data" and it seemed to be the right choice.
Admin_data works great locally but when I deploy it to heroku I just get the message "We're sorry, but something went wrong. (500)". If I restrict access I get the correct response of "not authorized".
I have no idea what's going wrong, and more importantly, don't know how to look into the cause of the error. Any tips on getting a verbose message from heroku or tuning admin_data are much appreciated.
Thanks!
'admin_data' by default only works in a 'development' environment.
You can either set your Heroku app to 'development' environment (http://docs.heroku.com/config-vars) or add your environment to an 'admin_data' config file (config instructions for a Rails 3 app are here: https://github.com/neerajdotname/admin_data/wiki/admin_data-security-configuration-for-a-Rails3-application):
AdminData.config do |config|
config.is_allowed_to_view = lambda {|controller| return true if (Rails.env.development? || Rails.env.test?) }
config.is_allowed_to_update = lambda {|controller| return true if (Rails.env.development? || Rails.env.test?) }
end