I have been using RoRfor a few days, so excuse me if this is a basic
question.
I am trying to save a model object from an action in a controller.
When I call a method on the model object that causes a state change,
then call save, no sql is generated.
However, if I modify the model object property directly from the
controller, then call save, sql is generated.
I have been using RoRfor a few days, so excuse me if this is a basic
question.
I am trying to save a model object from an action in a controller.
When I call a method on the model object that causes a state change,
then call save, no sql is generated.
However, if I modify the model object property directly from the
controller, then call save, sql is generated.
The first thing is that save on an unchanged object is a no-op as of
rails 2.1 (when partial updates was added).
def modifyModel
aDate = Date\.today
end
This method does not change the aDate attribute: it just sets a local
variable called aDate (which is forgotten about as soon as that method
returns). To disambiguate and force ruby to call your accessor you
need to do self.aDate = Date::today