Set checkboxes for has_many: through association using Formtastic

I have these models:

Sentence

class Offer < ActiveRecord::Base has_many :lists has_many :documents end 

List

 class List < ActiveRecord::Base belongs_to :user belongs_to :offer has_many :entries, :dependent => :destroy accepts_nested_attributes_for :entries, :allow_destroy => true end 

Element

 class Entry < ActiveRecord::Base belongs_to :list belongs_to :document end 

User

 class User < ActiveRecord::Base has_many :lists, :dependent => :destroy end 

I am using ActiveAdmin , before my change I had this form for List :

 form do |f| f.inputs "Détails Utilisateurs" do f.input :user end f.inputs "Accès" do f.has_many :entries, {:title => '', :link => 'Ajouter un document'} do |c| c.inputs '' do if not c.object.id.nil? c.input :_destroy, :as => :boolean, :label => "Supprimer l'accès" end c.input :document, :include_blank => false, :collection => offer.documents, :member_label => :to_label end end end f.buttons end 

But now I want to use the checkbox instead of the add / remove link buttons, so I'm doing something more like this:

 form do |f| f.inputs "Détails Utilisateurs" do f.input :user end f.inputs "Accès" do f.input :entries, :as => :check_boxes, :collection => offer.documents end f.buttons end 

But I did not specify the correct name in the checkbox, I tried: params param and html_options, but they have no effect. Any idea to fix this?

+4
source share

Source: https://habr.com/ru/post/1442712/


All Articles