netzke / netzke-core

Framework for Sencha Ext JS + Ruby on Rails client-server components
http://netzke.org
Other
263 stars 77 forks source link

Dependent model saving #63

Closed ebinjo13 closed 11 years ago

ebinjo13 commented 11 years ago

Two classes were created

class Supplier < ActiveRecord::Base  

  has_one :account, foreign_key: "acc_sup_id", :autosave => true  

  self.primary_key = 'sup_id'  

  attr_accessible :name, :remark

end  

class Account < ActiveRecord::Base 

  belongs_to :supplier, foreign_key: "acc_sup_id"  

  self.primary_key = 'acc_id'  

  self.table_name = 'accounts'  

  attr_accessible :dep, :rev

end

and netzke form is given as

class SupplierForm < Netzke::Basepack::Form

    def configure(c)

    c.model = 'Supplier'

    super

    c.items = [

      {field_label: "Name", name: :name},

      {field_label: "Remark", name: :remark},

      {field_label: "Dep", name: :account__dep, xtype: :checkbox, nested_attribute: true},

      {field_label: "Rev", name: :account__rev, xtype: :checkbox, nested_attribute: true}      
    ]

  end

end

Here I am getting two issues while saving

1) while inserting only name and remark is saved but not the nested attributes. 2) If the nested attribute fields set to checked the value is updated to DB but if unchecked update is not working

mxgrn commented 11 years ago

This does not belong in issues, and less so in Core. I'd recommend using the mailing list for this kind of questions.