Rails 2.0.1, Pow.cx - config.ru error - ruby-on-rails

I have rails 2.0.1 and the latest version of pow.cx setup and I'm getting an error which I think is related to the config.ru file:
NameError: uninitialized constant ActionController::Dispatcher
~/repos/selfsale-001/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:263:in `load_missing_constant'
~/repos/selfsale-001/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in `const_missing'
~/repos/selfsale-001/config.ru:3
~/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.4.0/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/repos/selfsale-001/config.ru:1:in `new'
~/repos/selfsale-001/config.ru:1
my config.ru is:
# Rails.root/config.ru
require "./config/environment"
run ActionController::Dispatcher.new
So ActionController isn't initialised, my question is what needs to be initialised for this setup? I have scoured Google and haven't found a config that works yet.
Any help would be greatly appreciated.

Hm.. my guess would be that you need to use at least Rails 2.3 to have a running Rack middleware, see
http://edgeguides.rubyonrails.org/2_3_release_notes.html
So, for Rails earlier than 2.3, your config.ru can not be used.

Related

Libxml-ruby error on Rails app startup -- uninitialized constant LibXML::XML::Error::I18N

I just updated to Rails 3.2.12 and Bundler also updated libxml-ruby from 2.4.0 to 2.5.0. When I restart my production server (nginx), or try to open a console, I get:
/home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:10:in `const_get': uninitialized constant LibXML::XML::Error::I18N (NameError)
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:10:in `block (2 levels) in <class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:8:in `each'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:8:in `block in <class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:7:in `tap'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:7:in `<class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:5:in `<module:XML>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:4:in `<module:LibXML>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:3:in `<top (required)>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml.rb:11:in `<top (required)>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/xml.rb:13:in `<top (required)>'
I'm not having the same issue on my dev box.
All I can figure is that some how the 2.5.0 gem is still referencing the old 2.4.0 compiled libraries and that particular constant is not defined in them. But no idea how this would happen nor how to rectify it. Nor whether this is even correct.
Any thoughts would be welcome.
I had the same problem, it fails on production but works on local. I tried freezing the version of the gem libxml-ruby to 2.4.0 and it works like a charm.
Hope it helps!
The issue happened on older versions of libxml. I just released an updated version of libxml-ruby, 2.6.0, that should resolve the issue.

active_support/whiny_nil.rb:52:in `method_missing' error occurs when I upgrade my rails 2.3.3 project to 2.3.17

Our rails project version is 2.3.3. Recently, however, we decided to upgrade rails version to 2.3.17 to patch the security holes.
But after upgrade my rails gem, I got the following error.
Is there anyone whoh had a same problem?
benjamins-iMac:webapp benjamin$ script/server
=> Booting WEBrick
=> Rails 2.3.17 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/rails/gem_dependency.rb:21.
/Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activerecord-2.3.17/lib/active_record/associations.rb:48: warning: already initialized constant HasManyThroughCantAssociateThroughHasManyReflection
/Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/whiny_nil.rb:52:in `method_missing': undefined method `name' for nil:NilClass (NoMethodError)
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:445:in `initialize_database_middleware'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:182:in `process'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:113:in `send'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:113:in `run'
from /Users/benjamin/clue/webapp/config/environment.rb:6
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/commands/server.rb:84
from script/server:3:in `require'
from script/server:3
benjamins-iMac:webapp benjamin$
And the ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:445's code is
ActionController::Base.session_store.name == 'ActiveRecord::SessionStore'
I resolved the problem.
The answer was at here.
http://johnpwood.net/2009/09/04/disabling-sessions-in-rails-2-3-4/
The error is never enough information to go off of alone. however, so simple things, did you run: sudo rake gems:install already?
Also, the database columns must be present for your ActiveRecord models to pick up. If the initial state is "no-database" and subsequent rake tasks call on models, then it would choke on nils. I see environment.rb in the stack trace, so I assume it got that far...
So you should note that if you are upgrading from older version to the newer one then environment.rb file also needs to be changed apart from others. See carefully the changes that you need to done specially the initializer tasks as all the problem lies there according to the error log.

Authlogic problem in production mode: undefined local variable or method `acts_as_authentic' for class name

I'm using the AuthLogic gem in my rails app. It works fine in the development environment but when I switch to production environment, I get an error preventing the app from starting:
/home/.../rails/xxx/app/models/book.rb:2: undefined local variable or method `acts_as_authentic' for Book:Class (NameError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:265:in `require_or_load'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:224:in `depend_on'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:136:in `require_dependency'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:414:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:413:in `each'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:413:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:411:in `each'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:411:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:197:in `process'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
from ./public/../config/environment.rb:28
from ./public/dispatch.fcgi:21:in `require'
from ./public/dispatch.fcgi:21
I'm using authlogic (2.1.5) and rails (2.3.8)
The error only happens in the production environment, even though my production and dev DB's are identical. Same issue on localhost as on the web server. I would really appreciate any help I can get with this. Please let me know if more info is needed. Much thanks!
Edited Sept 15:
Thanks for the replies. It's frozen into my application. I'm not sure how to verify that it's installed in such a way as to be available to the user I run my web server as. Here is the output of rake gems RAILS_ENV=production :
rake gems RAILS_ENV=production
(in /Users/my_user_name/Sites/my_app_name)
- [F] authlogic
- [R] activesupport
- [F] acts-as-taggable-on = 2.0.0.rc1
- [R] rails
- [F] will_paginate
- [I] nokogiri
I = Installed
F = Frozen
R = Framework (loaded before rails starts)
Edited Sept 17:
I tried unfreezing the gems and got the same error.
Is the authlogic gem installed in your production environment or frozen into your application? Also, is it installed in such a way as to be available to the user you run your web server as? (Apologies if you've already checked this but it makes sense to start at the beginning)
Finally, it would be worth checking that your config.gem "authlogic" call in environment.rb is before any use of your Book class which appears to be causing the problem.

Ruby Railroad diagram generator fails with NoMethodError for [] in Enumerable::Enumerator

I'm trying to generate model diagrams using the railroad gem. I have managed to generate a diagram for a different app, but I'm trying to get my head around some "legacy" code, and keep running into problems.
I know very little about ruby or rails, so any help would be appreciated...
Basically, I run:
$ railroad -v -M
and get:
Loading application environment
Loading application classes
./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/string/access.rb:43:in `first': undefined method `[]' for #<Enumerable::Enumerator:0xb70a72d0> (NoMethodError)
from ./config/../vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:70:in `has_attachment'
from ./app/models/asset.rb:5
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `load_classes'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `each'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `load_classes'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:21:in `initialize'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:14:in `initialize'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/bin/railroad:36:in `new'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/bin/railroad:36
from /home/myname/.gem/ruby/1.8/bin/railroad:19:in `load'
from /home/myname/.gem/ruby/1.8/bin/railroad:19
I've tried reinstalling attachment_fu (it was already in the vendor/plugins folder) but that didn't seem to help.
I wouldn't be surprised if there was a problem with the schema - I've already had to fix typos in column names, missing references, that kind of thing. Is there anyway I can work out where it might be dying?
Thanks a lot!
Your version of Ruby, probably 1.8.7 or even more recent, is too modern for attachment_fu. To fix this, you need to change attachment_fu itself. Edit the file vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb and on line 66 change:
options[:path_prefix].first == '/'
(at the end) to
options[:path_prefix].starts_with? == '/'
Alternatives are to downgrade your version of Ruby to 1.8.6 (probably, perhaps even lower) or use a different plugin. Attachment_fu is not supported any longer. Paperclip is used these days.
This error is described in more detail here.

`load_missing_constant' after installing Typus rails plugin

Getting an odd error. Just installed the Typus rails admin plugin, which is supposed to work in 2.3.2. However, after install it seems to mess with my user model. Not sure where to start here, any ideas?
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
/Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant Typus::Authentication::ByPassword (NameError)
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from /Users/apple/Sites/app/app/models/user.rb:10
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_file'
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:379:in `load_file'
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:259:in `require_or_load'
from /Users/apple/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:425:in `load_missing_constant'
... 35 levels...
from /Users/apple/.gem/ruby/1.8/gems/rails-2.3.2/lib/commands/server.rb:84
from /Library/Ruby/Site/1.8/rubygems
/custom_require.rb:31:in gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
from script/server:3
Are you using restful_authentication?
If so, there's a name conflict between the 'Authentication' module restful_authentication provides and the one included in Typus.
I renamed all the references to restful_authentication's modules from Authentication to RestfulAuthentication, and changed the module name in vendor/plugins/restful_authentication/lib/authentication.rb. Not sure if there's a better way to specify which module the model should use.
Alternatively, you can prefix the Restful Authentications with :: to clear up the discrepancy,
::Authentication instead of Authentication

Resources