I have an application working in localhost and also heroku. The last time that I pushed the new version to heroku I got an error during heroku db:migrate and did heroku db:push and everything was ok.
I get the following error when executing the App.
/app/.bundle/gems/ruby/1.9.1/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library': uninitialized constant AnswersController::Authentication (NameError)
Here is the relevant code
class AnswersController < ApplicationController
include Authentication
...
Authentication is a module defined in lib:
# encoding: utf-8
require 'base64'
require 'openssl'
module Authentication
...
It is working in localhost but not in heroku.
Any help??
Thanks
Try adding the lib folder to your the config.auto_load path in application.rb
config.autoload_paths += %W(#{config.root}/lib)
Also, take a look at this link.
Related
I have a Rails 3.1 app, which utilizes the Shopify API gem to fetch some external data via ActiveResource. We store these ActiveRecord model objects in Memcached via Dalli, and then read in again when needed.
We can successfully read in this data when running the Thin webserver, and everything works fine. However, once I setup Unicorn as the webserver then I continue to get the following error when reading the model object from Memcached:
Cache read: shopcache_987102
DalliError: Unable to unmarshal value: undefined class/module ShopifyAPI::Order::ClientDetails
Completed 500 Internal Server Error in 395ms
This does not happen on every read, but regularly enough to be a big problem. It only happens when we spawn more than 1 Unicorn worker process.
Below is my unicorn.rb file:
worker_processes 3
timeout 30
preload_app true
after_fork do |server, worker|
#Re-connect to ActiveRecord
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info('Connected to ActiveRecord')
end
end
We also have the following activated:
config.cache_classes = true
If I only spawn up a single Unicorn worker_process (worker_processes 1) then all works fine. I have tried setting config.threadsafe! in application.rb and this does not help with multiple workers.
It seems that the needed class/module is not being required, and I cannot work out why.
EDIT:
I've also added the following to my applicaton.rb file to try and add the gem to the autoload path of rails, without success:
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]
I've also added to the application_controller.rb require_dependency 'shopify_api' like so:
require 'current_shop_detail'
class ApplicationController < ActionController::Base
protect_from_forgery
include CurrentShopDetail
require_dependency 'shopify_api'
end
but I'm unsure if this is the correct way to do a require_dependency, seeing as the missing class is: ShopifyAPI::Order::ClientDetails
Any ideas? Thanks :)
I have a rails app set up with Nginx + Passenger. When i have rails_env development; on my nginx.conf everything works fine, but when I remove it so the app get server on production env it just doesnt work, seems like its not loading gems or something. Feel free to take a look at the errors here www.luisurraca.co.cc
error message:
undefined method `has_attached_file' for #<Class:0x00000003b0be10>
Exception class:
NoMethodError
Right now its referring to the paperclip gem, but if i start removing gems from the gemfile it will display error from some other gem and so on.
Any ideas what the issue might be?
You probably defined paperclip/whatever in development group and it is not installed with bundle install --deployment. To see installed gems do bundle show not gem list.
did you specify ruby path for nginx? it should look like this:
http {
passenger_root /home/rlisowski/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13;
passenger_ruby /home/rlisowski/.rvm/wrappers/ruby-1.9.3-p194/ruby;
# ....
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
I have a sample app that is using compass gem including blueprint. I just deployed this app on heroku for the first time and I'm seeing the following error in heroku logs
Errno::EACCES (Permission denied - /app/public/stylesheets/ie.css):
Is there something special required in my rails app that will make this error go away? I'm assuming it's coming because I'm using the compass gem...
Do a compass compile before deploying to heroku.
Also, in your production.rb, add the following line:
Sass::Plugin.options[:never_update] = true
This will prevent compass from compiling css at runtime (since heroku does not allow writes on filesystem)
Just set this option to true in config/environments/production.rb and everything will work fine:
config.assets.compile = true
Save ie.css from your local machine, add it into your public/stylesheets folder, and push it up to heroku.
I'm having the same heroku rake issues described (and from what I can tell solved) in this question.
When I try the fix (include require 'rake/dsl_definition' above require 'rake') I get the same
'uninitialized constant Rake::DSL'
error from heroku + I get the error
'no such file to load -- rake/dsl_definition'
from my local rake.
Without incorporating the fix (using the standard rakefile) I can use rake on my local setup with no errors (with the same heroku error)
I'm using rake version 0.8.7 (though I get the same results using 0.9.2) and Rails 3.0.9. I've gone through the suggestions in the previous question but from what I can tell the problem isn't with my Gemfile. Has anyone else had this problem? Has anyone else solved their heroku rake problem using a different solution? Or can anyone explain/suggest how I'm going about this incorrectly?
Thank you for your help.
Try adding require 'rake/dsl_definition' on top of Rakefile.
Not enough for me. I was getting the no such file to load -- rake/dsl_definition error even adding the require 'rake/dsl_definition' line in the "Rakefile" file
I had all gems version OK and only 0.8.7 rake version but I had to create a "Gemfile" in the redmine root path with the next content:
gem "rake", "0.8.7"
And delete the require 'rake/dsl_definition' line added previously in Rakefile
Hope be usefull for someone