views:

287

answers:

3

Have an app that has "listings" - think classified ads - and each listing has a list of tags.

The following code fails when I run the app in production mode, but works fine under development mode

uninitialized constant ActiveRecord::Acts::Taggable::InstanceMethods::TagList
Extracted source (around line #45):

42:         
43:         <span class="listingIndexTags">
44:             Location: [location] | Tags:
45:             <% tag_list = listing.tag_list %>
46:             <% if tag_list != nil %> 
47:                 <% for tag in tag_list %>
48:                     <%= link_to tag.to_s, { :action => "filter_on",

The command line I'm using to start my mongrel instance in this test case: ruby script/server mongrel -e production

Defaults to port 3000. I can access other views in the app that DON'T call "listing.tag_list".

".tag_list" is provided by "acts_as_taggable_on_steroids", which I'm using in this app. It is installed as a gem.

Maybe my environment files are wonky?

Here's my development.rb file

config.cache_classes = false

config.whiny_nils = true

config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs                         = true
config.action_controller.perform_caching             = false

config.action_mailer.raise_delivery_errors = true

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  ...took these settings out for this post...
}

And my production.rb file...

config.cache_classes = true
config.threadsafe!  

config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching             = true

config.cache_store = :mem_cache_store

config.action_mailer.raise_delivery_errors = false

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  ...took these settings out for this post...
}
A: 

Do you have the acts_as_taggable_on_steroids gem installed on your production server?

John Topley
I do. The same thing happens on my development machine, as it turns out, when I start mongrel in "production" environment, so nothing specific to the server as it turns out.I've also got the 'config.gem "acts_as_taggable_on_steroids' line in my environment.rb file, so I would expect that it would apply to all environments, if I'm understanding that properly.
normalocity
So is the gem listed if you run `gem list` on the server?
John Topley
@John Topley - yes it is in that list.
normalocity
A: 

FIXED:

Well, after putting off fixing this bug until I absolutely had to (today), I at long last found the source of the issue.

The inclusion of the line: config.threadsafe!

In my "production.rb" file was causing it.

I finally found it by:
    1. Making my production and development environment files identical
    2. Line-by-line, changing the production environment file until it either:
      a. The app broke in production mode
      b. I was back to my original production file

Anyhow, when I got to adding the "config.threadsafe!" line - IT BROKE! I was never so happy to have an app break.

So, a little reading to understand what exactly this option does, in conjuction with Mongrel (if Mongrel is even relevant), and I'll have my answer.

normalocity
A: 

Came along here with the same problem and just wanted to hand a note to everyone experiencing the same....I've managed to sort this problem this by fixing the version of gems in environment.rb

changed this
config.gem "acts-as-taggable-on", :source => "http://gemcutter.org"

to this:
config.gem "acts-as-taggable-on", :source => "http://gemcutter.org", :version => '2.0.0.rc1'

and run a rake gems:install

I wonder if you somehow were running different gems on different environments if that is possible.

flunder