Java like ear / Cache / Class in Ruby?

Hi,

We are facing a very weird situation. We do not face the problem in
our local but face it on the web service where we hosted. Seems like
the kinda of issues we have in java where either code stayed in cache
and not clearing even after server restart or ear deployment issues,
etc.

Our model is as follows. User can have one contact. The contact
sometimes should have country and state mandatory.

class User < ActiveRecord::Base
has_one :contact, :as => :contactable

class Contact < ActiveRecord::Base
belongs_to :contactable, :polymorphic => true
attr_accessor :validate_country, :validate_state
validates_presence_of :country, :if => “validate_country”
validates_presence_of :state, :if => “validate_state”

We are not calling @user.contact.validate_country = true anywhere but
when doing @user.save on creation, we get an effort that cannot find
function validate_country.

We also tried some varieties of code.
attr_accessor “validate_country”, “validate_state”
attr_accessible :validate_country, :validate_state
attr_accessible “validate_country”, “validate_state”

Can anything think of something?

Can someone please help us with this error?
It’s blocking basic functionality of our application

Can someone please assist on this?

The :if clauses should be symbols, not strings. BTW, bumping a post
twice in the space of an hour is a great way to get the group to
ignore you.

–Matt J.

The exact exception is

undefined local variable or method validate_country' for #<Contact: 0xb7116d9c> /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ attribute_methods.rb:260:inmethod_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:180:in evaluate_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:180:inevaluate_method’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:180:in instance_eval' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:180:inevaluate_method’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:195:in should_run_callback?' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:180:inall?’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:195:in each' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:195:inall?’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:195:in should_run_callback?' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:166:incall’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:90:in run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:90:ineach’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:90:in send' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:90:inrun’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:276:in run_callbacks' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ validations.rb:1029:invalid_without_callbacks?’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
callbacks.rb:315:in valid?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ associations/association_proxy.rb:221:insend’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
associations/association_proxy.rb:221:in method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ autosave_association.rb:249:inassociation_valid?’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
autosave_association.rb:229:in validate_single_association' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ autosave_association.rb:183:invalidate_associated_records_for_contact’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:180:in evaluate_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:180:inevaluate_method’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:180:in instance_eval' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:180:inevaluate_method’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:166:in call' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:90:inrun’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:90:in each' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:90:insend’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/
callbacks.rb:90:in run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/ callbacks.rb:276:inrun_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
validations.rb:1029:in valid_without_callbacks?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ callbacks.rb:315:invalid?’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
validations.rb:1008:in save_without_dirty' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ dirty.rb:79:insave_without_transactions’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
transactions.rb:229:in send' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ transactions.rb:229:inwith_transaction_returning_status’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
connection_adapters/abstract/database_statements.rb:136:in
transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ transactions.rb:182:intransaction’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
transactions.rb:228:in with_transaction_returning_status' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ transactions.rb:196:insave’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/
transactions.rb:208:in rollback_active_record_state!' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/ transactions.rb:196:insave’
/home/viridian/rails_apps/backstage/app/controllers/
users_controller.rb:84:in `create’