February 23rd, 2008, 05:24 PM
You're not going to get that method called when the value is not set in the checkbox. That's because the HTTP protocol will not send the field value if the checkbox is not set. The solution is to
1. Set the underlying model's default value to 0 for the field, so when you create a new instance, the default is set.
2. Check if model.within is set after you've set the other values and then set it yourself, if it isn't:
model = Model.new(params[:model])
model.within = 0
3. Override the new method for your model and make it set the value of model.within first before updating with all the passed in params.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne