What I'm seeing looks a LOT like this one:
http://groups.google.com/group/activescaffold/browse_thread/thread/d77e854b79987112/0dda64b8a0d4c7ce
Here's my setup (as previously seen in bug report #632!)
class Venue < ActiveRecord::Base
after_save :broadcast_primary_code
has_many :venue_attribute_values, :dependent => :destroy
belongs_to :venue_stage
validates_presence_of :venue_stage
validates_presence_of :primary_code
validates_uniqueness_of :primary_code
def broadcase_primary_code
logger.warn primary_code
end
end
class VenueStage < ActiveRecord::Base
has_many :venues
has_and_belongs_to_many :venue_attributes, :uniq => true
end
class VenueAttribute < ActiveRecord::Base
has_many :venue_attribute_enums, :dependent => :destroy
has_many :venue_attribute_values, :dependent => :destroy
has_and_belongs_to_many :venue_stages
validates_presence_of :name
validates_uniqueness_of :name
end
class VenueAttributeEnum < ActiveRecord::Base
belongs_to :venue_attribute
has_many :venue_attribute_values, :dependent => :destroy
validates_presence_of :value
end
class VenueAttributeValue < ActiveRecord::Base
belongs_to :venue
belongs_to :venue_attribute_enum
belongs_to :venue_attribute
validates_presence_of :venue
validates_presence_of :venue_attribute
validates_presence_of :venue_attribute_enum
end
class VenuesController < ApplicationController
config.columns[:venue_stage].form_ui = :select
end
or:
venue_attribute_values ----> venues -----------> venue_stages
| | ^
| +---------------------+ |
| | |
v v |
venue_attribute_enums -> venue_attributes <-
venue_attributes_venue_stages
When I save a venue, updating only the primary_code field (FROM ZZTxy
TO ZZT), the submission form includes updates for all of the
venue_attribute_values included. When being processed, I see
something like this for each venue_attribute_value in the form:
VenueAttributeEnum Load (0.000223) SELECT * FROM
`venue_attribute_enums` WHERE (`venue_attribute_enums`.`id` = 26)
Venue Load (0.000351) SELECT * FROM `venues` WHERE (`venues`.`id`
= 1255)
VenueAttribute Load (0.000221) SELECT * FROM `venue_attributes`
WHERE (`venue_attributes`.`id` = 17)
Then this:
SQL (0.001134) SELECT `primary_code` FROM `venues` WHERE (LOWER
(`venues`.primary_code) = 'zzt' AND `venues`.id <> 1255)
Followed by a block of these:
SQL (0.000220) SELECT `name` FROM `venue_attributes` WHERE
(`venue_attributes`.name = 'Serves_Food' AND `venue_attributes`.id <>
5)
MetroArea Load (0.000205) SELECT * FROM `metro_areas` WHERE
(`metro_areas`.`id` = 1)
VenueStage Load (0.000188) SELECT * FROM `venue_stages` WHERE
(`venue_stages`.`id` = 1)
SQL (0.001052) SELECT `primary_code` FROM `venues` WHERE (LOWER
(`venues`.primary_code) = 'zztxy' AND `venues`.id <> 1255)
Then this:
Venue Update (0.000378) UPDATE `venues` SET `updated_at` =
'2008-12-03 16:51:03', `primary_code` = 'ZZT' WHERE `id` = 1255
ZZT
Followed by a block of these:
ZZTxy
The blocks are each one per venue_attribute_value in the form, and
they happen after venue is updated, but with the old value of
primary_code. Of course the real code is doing something interesting
with primary_code, so this is not just weird but bad.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---