[Vuejs]-Rails Deep Nested Attributes to Vue Instance with JSON

0👍

This was solved using Jbuilder to generate a JSON object using the necessary appended names.

For example:

json.product do
  json.coverages_attributes product.coverages do |coverage|
    json.minimum_premium_rules_attributes coverage.minimum_premium_rules do |minimum_premium_rule|
      json.(minimum_premium_rule, :minimum_premium)
    end
  end
end

The coverage.minimum_premium_rules retrieved from the database were passed into vue using the proper nested attribute naming – minimum_premium_rules_attributes -that Rails needs to update the record.

Leave a comment