When you generate a new Phoenix model the changeset function uses struct:
However in most tutorials I have seen programmers use the model approach:
My question is, when should one use model or struct? Thanks for your time
Phoenix switched from
struct in 1.2. So, the tutorials you’re reading will have been written for < 1.2.
You can see the commit here
Either will technically work because it’s just a variable name, but you should always use
struct. Phoenix made the decision to move away from the
model term as it implies some sort of coupling (a’la Rails) where none existed. That, and the first argument to a changeset is always a literal struct, anyway.
Hope that helps!