Open tfe opened 14 years ago
When you remove the plugin does the error go away?
I can't see how this plugin would affect the exists? method. I'm using Rails 2.3.5 and it's working fine for me. The objects get instantiated and the setter methods (@model.myattr = 'x') never gets called.
Can you check that this code works when you remove the plugin? How about if the plugin is installed but the "attr_immutable" call is commented out?
Also: thanks for reporting this :) If this is a bug then it means you're solving a problem I was bound to run into myself one day.
It definitely went away after removing the plugin. I wasn't using attr_immutable, just the validator method.
You're absolutely right, I wasn't testing with #exists? and the validator method. I've fixed it, pushed the changes, and released a new gem version.
Thanks for all your help!
The presence of this plugin on one of my models seems to be breaking the AR exists? method. I think it's because exists only selects IDs, and when AR tries to instantiate objects with only the ID present, immutable_attributes freaks out.
In this example mymodel is the model and myattr is the immutable attribute, and also the attribute I'm passing to exists?, like so: MyModel.exists?(:myattr => 'foo').