         |> put_flash(:info, "User updated successfully.")
         |> redirect(to: user_path(conn, :show, user))
       {:error, changeset} ->
+        roles = Enum.map(Repo.all(Role), fn(x) ->
+          { x.name, x.id }
+        end)
         render(conn, "edit.html", user: user, changeset: changeset, roles: roles)
     end
   end

  def update(conn, %{"id" => id, "user" => user_params}) do
    user = Repo.get!(User, id)
    changeset = User.update_changeset(user, user_params)
    roles = Enum.map(Repo.all(Role), fn(x) ->
      { x.name, x.id }
    end)

    case Repo.update(changeset) do
      {:ok, user} ->

    end

    changeset = User.changeset(%User{}, user_params)

    case Repo.insert(changeset) do
      {:ok, _user} ->
