     end
   end
 
-  def edit(conn, params) do
-    post = Repo.get!(Post, params["id"])
-    post = Post.changeset(post)
+  def edit(conn, %{ "id" => id }) do
+    post = Post |> Repo.get!(id) |> Post.changeset
     render conn, "edit.html", changeset: post
   end
 
-  def update(conn, params) do
-    changeset = Post.changeset Repo.get!(Post, params["id"]), params["post"]
+  def update(conn, %{ "id" => id, "post" => post_params }) do
+    changeset = Post |> Repo.get!(id) |> Post.changeset(post_params)
     if changeset.valid? do
       post = Repo.update(changeset)
       conn

    end
  end

  def delete(conn, params) do
    Post.destroy params["id"]
    conn
      |> put_flash(:notice, "Post deleted!")
      |> redirect to: posts_path(conn, :index)

    render conn, "new.html", changeset: changeset
  end

  def create(conn, %{ "post" => post_params }) do
    changeset = Post.changeset %Post{}, post_params
    if changeset.valid? do
      post = Repo.insert(changeset)
      conn
