HI All,
I am having Model “Customer” using STI for sender and receiver, and i am
unable to save the both sender and receiver by nested attribute. Below
are
my model and active admin resource codes, correct me if i am wrong
nested
attribute on concept.
CUSTOMER MODEL:
class Customer < ActiveRecord::Base
belongs_to :sender, :class_name => “Customer”
has_many :receivers, :class_name => “Customer”, :foreign_key =>
‘sender_id’
has_many :packages
accepts_nested_attributes_for :packages
accepts_nested_attributes_for :receivers
end
CUSTOMER ADMIN INTERFACE:
ActiveAdmin.register Customer do
form do |f|
f.inputs “Sender Details” do
f.input :name
f.input :email
f.input :street
f.input :city
f.input :state
f.input :pin
end
f.inputs do
f.has_many :receivers do |p|
f.input :name
f.input :email
f.input :street
f.input :city
f.input :state
f.input :pin
end
end
f.inputs do #packages are saving correctly
f.has_many :packages do |p|
p.input :weight
p.input :amount
p.input :received_date
p.input :amount
end
end
f.buttons
end
end
regards,
Loganathan