venue_attribute_values ----> venues -----------> venue_stages
    |    |                                             ^
    |    +---------------------+                       |
    |                          |                       |
    v                          v                       |
venue_attribute_enums -> venue_attributes <-
venue_attributes_venue_stages

or:

class Venue < ActiveRecord::Base
  has_many :venue_attribute_values, :dependent => :destroy
  belongs_to :venue_stage
  validates_presence_of    :venue_stage
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
end

class VenueAttributeEnum < ActiveRecord::Base
  belongs_to :venue_attribute
  has_many :venue_attribute_values, :dependent => :destroy
end

class VenueAttributeValue < ActiveRecord::Base
  belongs_to :venue
  belongs_to :venue_attribute_enum
  belongs_to :venue_attribute
end

class VenuesController < ApplicationController
    config.columns[:venue_stage].form_ui = :select
end

Processing VenuesController#update (for 70.253.83.147 at 2008-11-30
20:24:47) [PUT]
{
"commit"=>"Update",
"_method"=>"put",
"action"=>"update",
"id"=>"1247",
"controller"=>"venues",
"record"=>
{
  "venue_attribute_values"=>
  {
    "875"=>
    {
      "venue_attribute_enum"=>{"id"=>""},
      "venue_attribute"=>{"id"=>"10"},
      "id"=>"875",
      "venue"=>{"id"=>"1247"}
    }
  }
  "venue_stage"=>{"id"=>"1"},
}
}

Clears out venue_attributes#10.venue_stages

I'm pretty sure this is related to this question:
http://groups.google.com/group/activescaffold/browse_thread/thread/2c20f2054e109087/71c61f1acd883695?lnk=gst&q=association+delete#71c61f1acd883695.

Removing the delete grant from the db user in order to force an
exception led me to lib/attribute_params.rb, update_record_from_params
(parent_record, columns, attributes)
...
elsif column.form_ui and column.plural_association? and not
column.through_association?
  parent_record.send("#{column.name}=", [])
end
...

logger.warn "#{parent_record.class}:#{parent_record.id}"
logger.warn "columns: #{columns.map{|column| [column.name,
column.form_ui, !!column.singular_association?, !!
column.plural_association?]}.inspect}"
logger.warn "attrs: #{attributes.to_yaml}"

VenueAttribute:10
columns: [[:name, nil, false, false], [:venue_attribute_enums, nil,
false, true], [:venue_stages, :select, false, true], [:update_order,
nil, false, false]]
attrs: --- !map:HashWithIndifferentAccess
id: "10"


The first thing is that AS should use parent_record.send("#
{column.nam}.clear") (saves a query).  The second is that we are
treating the mere reference of an associated record as a full update
of that record.  I'm going to experiment with adding another
condition, "and attributes.keys != ['id']".

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to