How to handle associations and nested forms in Phoenix framework?
问题 What is the way to handle associations and nested forms in Phoenix framework? How would one create a form with nested attributes? How would one handle it in the controller and model? 回答1: There is a simple example of handling 1-1 situation. Imagine we have a Car and an Engine models and obviously a Car has_one Engine . So there's code for the car model defmodule MyApp.Car do use MyApp.Web, :model schema "cars" do field :name, :string has_one :engine, MyApp.Engine timestamps end def changeset