I am using ActiveAdmin in my rails application.My setup is the following:
app/models/translation_type.rb
class TranslationType < ActiveRecord::Base
has_many :translation_details
accepts_nested_attributes_for :translation_details, allow_destroy: true
end
app/models/translation_detail.rb
class TranslationDetail < ActiveRecord::Base
belongs_to :translation_type
attr_accessor :id, :language_from, :language_to, :price
end
app/admin/translation_type.rb
ActiveAdmin.register TranslationType do
permit_params :translation_type, translation_details_attributes: [:id, :language_from, :language_to, :price, :_destroy]
index do
column :translation_type
column :translation_details
column :created_at
column :updated_at
actions
end
filter :translation_type
filter :created_at
form do |f|
f.inputs "Translation Type Details" do
f.input :translation_type
f.input :created_at
f.input :updated_at
end
f.inputs do
f.has_many :translation_details, allow_destroy: true do |tran_det|
tran_det.input :language_from, :collection => ['Gr', 'En', 'Fr', 'De']
tran_det.input :language_to, :collection => ['Gr', 'En', 'Fr', 'De']
tran_det.input :price
end
end
f.actions
end
controller do
before_filter { @page_title = :translation_type }
end
I don't need a section for translation_detail
so I have omited app/admin/translation_detail.rb
I want to have nested forms of translation_detail
in my translation_type
form. Using the code above creates the nested form but after submit the attributes of translation_detail
are not saved. Furthermore when I try to update or delete a translation_detail
this message is shown
Couldn't find TranslationDetail with ID=* for TranslationType with ID=*
How can this be fixed?