defmodule <%= module %> do
  use <%= base %>.Web, :model

  schema <%= inspect plural %> do
<%= for {k, _} <- attrs do %>    field <%= inspect k %>, <%= inspect types[k] %><%= defaults[k] %>
<% end %>
    timestamps
  end

  @doc """
  Creates a changeset based on the `model` and `params`.

  If `params` are nil, an invalid changeset is returned
  with no validation performed.
  """
  def changeset(model, params \\ nil) do
    cast(model, params, ~w(<%= Enum.map_join(attrs, " ", &elem(&1, 0)) %>), ~w())
  end
end

defmodule <%= module %> do
  use <%= base %>.Web, :model

  schema <%= inspect plural %> do
<%= for {k, _} <- attrs do %>    field <%= inspect k %>, <%= inspect types[k] %><%= defaults[k] %>
<% end %>
    timestamps
  end

  @required_fields ~w(<%= Enum.map_join(attrs, " ", &elem(&1, 0)) %>)
  @optional_fields ~w()

  @doc """
  Creates a changeset based on the `model` and `params`.

  If `params` are nil, an invalid changeset is returned
  with no validation performed.
  """
  def changeset(model, params \\ nil) do
    cast(model, params, @required_fields, @optional_fields)
  end
end

Make required and optional fields clearer
Make required and optional fields clearer
CultivateHQ/phoenix,0x00evil/phoenix,Kosmas/phoenix,Rumel/phoenix,mitchellhenke/phoenix,nshafer/phoenix,daytonn/phoenix,andrewvy/phoenix,Smulligan85/phoenix,jxs/phoenix,Gazler/phoenix,sdnorm/phoenix,javimolla/phoenix,ericmj/phoenix,0x00evil/phoenix,Fluxuous/phoenix,milafrerichs/phoenix,tony612/phoenix,ybur-yug/phoenix,kyledecot/phoenix,seejee/phoenix,marcioj/phoenix,maxnordlund/phoenix,Gazler/phoenix,0x00evil/phoenix,evax/phoenix,romul/phoenix,evax/phoenix,mschae/phoenix,wicliff/phoenix,paulcsmith/phoenix,hsavit1/phoenix,ahmetabdi/phoenix,vic/phoenix,kholbekj/phoenix,eksperimental/phoenix,linearregression/phoenix,lancehalvorsen/phoenix,rafbgarcia/phoenix,korobkov/phoenix,robhurring/phoenix,keathley/phoenix,mobileoverlord/phoenix,begleynk/phoenix,scrogson/phoenix,ybur-yug/phoenix,stevedomin/phoenix,rodrigues/phoenix,optikfluffel/phoenix,cas27/phoenix,rafbgarcia/phoenix,GabrielNicolasAvellaneda/phoenix,bsodmike/phoenix,ugisozols/phoenix,ACPK/phoenix,robomc/phoenix,bsmr-erlang/phoenix,jwarwick/phoenix,ericmj/phoenix,eksperimental/phoenix,phoenixframework/phoenix,brucify/phoenix,optikfluffel/phoenix,Joe-noh/phoenix,mobileoverlord/phoenix,VictorZeng/phoenix,DavidAlphaFox/phoenix,thegrubbsian/phoenix,CultivateHQ/phoenix,ephe-meral/phoenix,iStefo/phoenix,henrik/phoenix,gjaldon/phoenix,greyhwndz/phoenix,arthurcolle/phoenix,switchflip/phoenix,nickgartmann/phoenix,Dahoon/phoenix,yoavlt/phoenix,kevinold/phoenix,dmarkow/phoenix,vic/phoenix,korobkov/phoenix,pap/phoenix,Rumel/phoenix,foxnewsnetwork/phoenix,trarbr/phoenix,elliotcm/phoenix,mvidaurre/phoenix,CD1212/phoenix,jamilabreu/phoenix,mitchellhenke/phoenix,nshafer/phoenix,omotenko/phoenix_auth,mvidaurre/phoenix,Kosmas/phoenix,mschae/phoenix,kidaa/phoenix,cas27/phoenix,beni55/phoenix,StevenNunez/phoenix,gjaldon/phoenix,trarbr/phoenix,Ben-Evolently/phoenix,jamilabreu/phoenix,rafbgarcia/phoenix,bsmr-erlang/phoenix,KazuCocoa/phoenix,nicrioux/phoenix,bdtomlin/phoenix,Eventacular/phoenix,xtity/simple_phoenix,doron2402/phoenix,manukall/phoenix,justnoxx/phoenix,safi/phoenix,FND/phoenix,yonglehou/phoenix,phoenixframework/phoenix,andrewvy/phoenix,wsmoak/phoenix,iguberman/phoenix,jasond-s/phoenix,esbullington/phoenix-1,nshafer/phoenix,stevedomin/phoenix,Joe-noh/phoenix,doomspork/phoenix,hotvulcan/phoenix,JHKennedy4/phoenix,y-yagi/phoenix,ephe-meral/phoenix,SmartCasual/phoenix,lono-devices/phoenix,keathley/phoenix,jeffweiss/phoenix,jwarwick/phoenix,sadiqmmm/phoenix,michalmuskala/phoenix,lono-devices/phoenix,lancehalvorsen/phoenix,Smulligan85/phoenix,dmarkow/phoenix,wsmoak/phoenix,phoenixframework/phoenix,michalmuskala/phoenix,rodrigues/phoenix,omotenko/phoenix_auth,stefania11/phoenix,jeffkreeftmeijer/phoenix,seejee/phoenix,optikfluffel/phoenix,iStefo/phoenix,DavidAlphaFox/phoenix,manukall/phoenix,fbjork/phoenix,pap/phoenix