Hi Paul, that s indeed a long story...
Maybe column option show_blank_record helps you. https://github.com/activescaffold/active_scaffold/wiki/API%3A-Column -- Volker On Apr 10, 5:05 pm, Paul Taylor <[email protected]> wrote: > Ok - This one is a bit hard to explain in words, especially since I > only dabble in RoR when the job requires it, but here goes: > > These models are the ones I'm having an issue with: > > class Farm < ActiveRecord::Base > belongs_to :vserver > has_many :reals, :foreign_key => 'farm_id', > :class_name => 'FarmsReal', > :dependent => :destroy > end > > class FarmsReal < ActiveRecord::Base > belongs_to :farm > belongs_to :real > end > > class Real < ActiveRecord::Base > belongs_to :switch > has_many :farms, :foreign_key => 'real_id', > :class_name => 'FarmsReal' > end > > Background: I'm writing a web interface to help us manage load > balancing on our Cisco core switches. Basically, the ActiveScaffold > app would be the way that changes would be planned out, then another > program will read the database, determine the way it should be > configured, and put that config in place on the switch. > > Back to the program: Basically a server farm (Farm, above) has many > Real servers associated with it and Real servers can be associated > with multiple farms, so they both have a has_many relationship to each > other, through the FarmReals model. In addition, the FarmReals model > stores the status of that individual connection between the farm and > the real (whether it's in service, or out of service). > > Anyhow, with ActiveScaffold, when I add a record, this works just > fine. I get the "Reals" subform pre-populated with a dropdown to > select one of the already created Reals. I can select one and it > works just as I'd expect. When I edit a Farm, I get the "Reals" > subform pre-populated with all the Reals that are already assigned, > and one more new one at the bottom, allowing me to add another Real. > The problem is that if I want to change something about the farm, or > if I want to delete a Real from the farm, when I try to perform the > update, I get an error "Reals is invalid", and it's complaining about > the Real that I intentionally left blank at the bottom of the Reals > form. There's not an "X" by it, like the other ones that have been > already added, so I can't manually delete it each time I edit (though > that's not the solution I really want anyhow). > > How can I fix this so that it will not pre-populate a blank dropdown > list at the bottom of the Reals subform? So, when I want to add a > real, I will hit the "Create Another" button thats at the bottom of > that subform. If it worked that way, this would be just fine. > > Thanks, > Paul Taylor -- 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.
