I finally got it working in ActiveAdmin without a custom form. I'll post how I did it for references if somebody need.
First I set my custom attributes in the LineItem model:
class LineItem < ActiveRecord::Base
attr_accessor :source
attr_accessor :target
(it doesn't work adding :source and :target to the ActiveAdmin file under permit_params, I get an error that there are no column with :source/:target if not added to the model with attr_accessor)
ActiveAdmin.register Order do
permit_params :id, :title,
line_items_attributes: [:id, :order_id, :language_pair_id, :source, :target]
f.has_many :line_items, :allow_destroy => true do |cf|
cf.input :source, :collection => Language.pluck(:lang)
cf.input :target, :collection => Language.pluck(:lang)
end
end
f.actions
end
controller do
def create
@order = Order.create(:title => params[:order][:title])
params[:order][:line_items_attributes].each do |x, y|
source = Language.find_by_lang(y[:source])
target = Language.find_by_lang(y[:target])
pair = LanguagePair.find_by(:source_id =>
source.id, :target_id =>
target.id)
@order.line_items.create(:language_pair => pair)
end
create!
end
end
end
it work flawlessly.
Thank you all for the help.