Heroku + Rails: weird error (Cedar Stack) - ruby-on-rails-3

So I have deployed my app to heroku for testing for a couple of weeks and since yesterday I keep getting the following kind of errors in the heroku logs:
Started GET "/user/shipping_address" for xx.xxx.xxx at 2012-02-09 15:46:37 +0000
NameError (undefined local variable or method `sign_up_path' for #<UsersController:0x000000036210a8>):
app/controllers/application_controller.rb:57:in `require_user'
Another one:
Started POST "/purchase/search" for xx.xxx.xxx at 2012-02-09 15:31:30 +0000
NameError (undefined local variable or method `sign_up_path' for #<PurchasesController:0x000000051a3d08>):
app/controllers/application_controller.rb:57:in `require_user'
I also keep getting (really) weird javascript errors in firebug, like "object_id" missing, where object_id should never be used at that point in code.
It works without any flaws in the local environment on development/production and also all the time before on my heroku app.
Any hints greatly appreciated. This error is really killing me.
Best, Phil
(Cedar-Stack, Rails 3.0, authlogic)

Ok I updated authlogic to the newest version 3.1.0 (think it was on 3.0.3) and everything works for now.

Related

Rails friendly_id: undefined method `slug` on production

I'm trying to introduce dynamic_sitemaps over resources with friendly_id. The issue is the production rails (rake / rails c) doesn't see the slug method. I've try to specify it by force by specifying an attr_accessible :slug, but it doesn't help either.
$ rake sitemap:generate
Generating sitemap...
rake aborted!
undefined method `slug' for #<Article:0xa9e4d14>
The funny thing it works smoothly on the local environment, and it should not be so much different with the capistrano/rvm deployment.
The column exists in the DB and is used by the rails app itself (which works fine too).
Added: it should be tied to either the environment or the specific gem version issue, but I'm not sure which one is the trouble, and how to debug it. The same pair works good for a different project with a pretty similar libraries bundle.
As the capistrano always do the dirty work, I forgot about the RAILS_ENV environment variable - so the console and cron job tried to operate against the dev DB and obviously failed.

Error message: NameError at /users/sign_in undefined local variable or method `require_no_authentication' for #<SessionsController:0x########>

I'm working on a RoR app with Devise. When I came in to work today and tried to start up my local dev environment, RoR failed when I tried to go to the sign in page:
NameError at /users/sign_in
undefined local variable or method `require_no_authentication' for #<SessionsController:0x########>
It looks like the error is not being raised within the code we wrote, but instead from deep within the Devise gem. I'm guessing that somehow, my dev machine isn't configured right.
Here are some things I've tried to fix the bug:
I ran rake db:migrate and rake db:terraform.
I ran bundle install.
I ran rvm gemset empty and bundle install to reinstall all of my gems.
None of these worked.
In addition, here are a couple more strange things about this error:
None of the other devs at my workplace are having the same error, even though they're on the same codebase.
After trying to figure out the error for a while, I switched to a branch that I haven't updated since before I started getting this bug. Even though it was working before the weekend, that branch now fails with the same error.
Does anybody know anything I could do to try to fix this error? Does it sound like some part of my local configuration is incorrectly set up?
In my project, I had added a file in app/controllers called devise_controller.rb. It looked like this:
class DeviseController < ApplicationController
# Asks Devise how much time is left until the current user is
# automatically logged out, without resetting the logout timer.
def time_until_logout
raise "let's inspect here"
end
end
When I deleted this file, the bug went away.
I filed a bug report about how adding a DeviseController caused RoR/Devise to blow up on Devise's repository: https://github.com/plataformatec/devise/issues/2520

Routing error while searching for javascript

My app worked a few days ago.
I have switched to 'thin' from webrick
now I get
2011-12-28T07:08:53+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/jquery.livequery-6725741b06c676d9173d5056b277caeb.js"):
I saw on other question that they were told to set this to true
config.serve_static_assets = false
but heroku recommends against that.
I have tried both using rake assets:precompile locally and then pushing and also without it and let heroku precompile.
Both give same error
How do I make sure the javascripts are served, compiled and available?
Why is the error occuring?
I'm using rails 3.1.3 on cedar, Latest Thin.
I was able to solve this using the question Rails 3.1 asset precompilation - include all javascript files
so.. problem solved

Error while running Metrical

I've a Ruby 1.9.2 and Rails 3.0.9 development environment. When I run the gem "metrical" on my application, I get the following errors:
** Running the specs/tests in the [test] environment
Analyzing: 100% |oooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:00
/Users/tester/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/emitter.rb:17:in `end_document': undefined method `write' for #<Syck::Emitter:0x000001028d2388> (NoMethodError)
Anyone else seen this issue? I'm out of ideas for the error.
I ran into the same problem, seems to be related to YAML parsing with Ruby 1.9.2
I hacked into metric fu and inserted a explicit requirement of the Psych YAML Engine:
metric_fu-2.1.1/lib/metric_fu.rb:
require 'rake'
require 'psych' # <-- added here
require 'yaml'
And now works...
The simplest solution is to set the RUBYOPT environment variable when you run metrical, so instead of metrical you type:
RUBYOPT='-rpsych' metrical
I am doing that and it's all working fine. This blog post figured it out for me: http://excid3.com/blog/undefined-method-write-for-syckemitter/ (possibly a bit simpler than hacking into metric_fu, until they fix this).

Debugging heroku 500 server error?

So this is what I get from looking at my production.logs from heroku:
Completed 200 OK in 63ms (Views: 6.0ms | ActiveRecord: 50.3ms)
Processing by EventsController#show as HTML
Parameters: {"id"=>"2"}
Rendered events/show.html.erb within layouts/application (3.7ms)
Completed 500 Internal Server Error in 15ms
Everything works locally and I have even pushed the database to heroku using db:push. Is there any more robust logging for heroku than the lines above that aren't helpful?
I'm sure its because you haven't ran rake db:migrate
If that does not work make sure that all the gems you need are in your Gem file, i.e. you are not making any local require statements to gems not in the Gemfile.
What I have found helpful is tailing the log.
And then you need to run this in console:
heroku logs --tail
Now click on the same page you were getting problems at before and check out the logs.
EDIT: on rails 4 you'll need to add the rails_12factor gem to get the detailed logs.
This isn't related to ruby but it might be good information for other googlers.
My issue not being able to see the actual error was that I was using a third party PHP tool that did this: # mysql_connect( ... ) which simply hides the error that that function didn't exist .. really evil code