Rails: Different prices for different branches, association depending on two other models combined
- by Greg Lemond
I have three models:
Service
has_many :prices
has_many :groups, through: prices
Price
belongs_to :service
belongs_to :group
Group
has_many :prices
I want to have an input field (Simple_Form) for every price.
In views/services/_form.html.haml I do:
simple_form_for @service do |f|
simple_fields_for :groups do |g|
simple_fields_for :prices do |p|
p.input :price
With this setup I only get input fields for already saved prices.
How I can get a price field for every group? I tried to do it manually, but it got really nasty and didn't work either.
Thanks for any ideas!