phoenix.gen.html
phoenix.gen.json
"At the end of the day, it ends up adding complexity to the framework—and, indirectly, to your application—only to save a few keystrokes every once in a while. " (p.93)
ex) mix phoenix.gen.html Video videos user_id:references:users url:string title:string description:text
- move
defp authenticate
to theRumbl.Auth
module - make it public
- share it across controllers by adding it to the web controller import
- add it to
pipe_through
in the router, within the/manage
scope
scrub_params
plug to protect against submission of empty strings
- similar to Rails generator
- schema: "This file is responsible for identifying the fields in a way that ties in to both the database table and the Elixir struct." (p.99)
- @variable means module attribute
- Ecto Associations are explicit; must ask expicitly for related data
- rewrite the
action
function in the controller to pass in the current user explicitly - "Using Ecto.assoc, we built a simple authorization rule restricting deletes and updates to the video’s owner." (p.104)