The layout and details
Routes
Just do it already!
MB:postit> mix phx.gen.html Posting Post posts title:string content:text * creating lib/postit_web/controllers/post_controller.ex * creating lib/postit_web/templates/post/edit.html.eex * creating lib/postit_web/templates/post/form.html.eex * creating lib/postit_web/templates/post/index.html.eex * creating lib/postit_web/templates/post/new.html.eex * creating lib/postit_web/templates/post/show.html.eex * creating lib/postit_web/views/post_view.ex * creating test/postit_web/controllers/post_controller_test.exs * creating lib/postit/posting/post.ex * creating priv/repo/migrations/20190717045929_create_posts.exs * creating lib/postit/posting.ex * injecting lib/postit/posting.ex * creating test/postit/posting_test.exs * injecting test/postit/posting_test.exs Add the resource to your browser scope in lib/postit_web/router.ex: resources "/posts", PostController remember to update your repository by running migrations: $ mix ecto.migrate MB:postit>That didn’t take long. Our first error. ?
assign @current_user not available in eex template.we’d forgotten to add the security plug to get for auth and the conditional in our Navbar is looking for current_user in order to render the login or logout buttons. happy that was simple.
Create a controller helper and add it in here!
There are two types of plugs in the Phoenix. They are module plugs and function plugs. We are going to cover both of them in this article.
having stumbled into it in an effort to ‘DRY’ out our code. And really, there will probably be more controllers in our app over time and I feel like I have really hit the sweet spot of learning
What is the difference between alias and import ?
alias use shorter name instead of the fully qualified name or prefix
changeset
conn
defp
JavaScript to Elm
Jesse Tomchak
Podchaser is the ultimate destination for podcast data, search, and discovery. Learn More