Brian Sammon
2014-Oct-15 21:01 UTC
before_update callback is called when new record is created
All my tables/models have a "revision" field, and I have a
before_update callback to increment the revision field.
Among my tables are:
events
rooms
events_rooms
In my Event model, I have:
has_many :eventRooms
has_many(:rooms, :through => :eventRooms)
When I create an event, assign a room or two, and then save, the
"events_rooms" table entry is initially created with a revision of 1,
and then (immediately, automatically, and inexplicably) updated to have
a revision of 2. I do not want every new record to have a revision
number of 2. The revision 2 version is identical to revision 1 (which
it replaces), aside from the revision number.
I can reproduce this in the rails console with the following:
event = Event.new({'name' => 'Meeting 5'})
event.rooms << Room.find(['1', '2'])
event.save
Does anyone have any idea why this could be happening or where I should
look for further troubleshooting?
I'm working trying to strip out all the weird stuff (there's a lot) that
I had in my app, and remove anything proprietary so I can make a simple
test case.
So far, none of my simplifications have made this problem go away.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/20141015170156.d51ede1ce4b44572de20ce20%40brisammon.fastmail.fm.
For more options, visit https://groups.google.com/d/optout.