Reputation: 8730
f.has_many :offers,heading: 'Offers' do |item|
item.input :quantity
item.input :offer_type_id, :prompt => 'Select Offer Type', :as => :select, :collection => OfferType.all.map{|m| [m.title, m.id]}
item.input :_destroy, :as => :boolean
end
It works fine and has_many association created. I want that the button for adding associated data automatically clicked or open when I load page.
Add new Offer
Instead that user click on it for first associated data it automatically clicked
Upvotes: 2
Views: 614
Reputation: 52357
In AA controller block you need yo build
offer - it will add the offer's fields to the form:
controller do
def new
super do
resource.offers.build
end
end
end
Upvotes: 1