Hey all! New to Elixir - I’m trying to edit an entry in postgresql, and I can’t see what I’m doing wrong - I keep getting this error when I try to access the URL. Want to be seeing a page with the entry passed in by its “id” in the path. see below:
router.ex:
scope "/", Discuss do
pipe_through :browser
get "/", TopicController, :index
get "/topics/new", TopicController, :new
post "/topics", TopicController, :create
get "/topics/:id/edit", TopicController, :edit
put "/topics/:id", TopicController, :update
end
controller:
def edit(conn, %{"id" => topic_id}) do
topic = Repo.get(Topic, topic_id)
changeset = Topic.changeset(topic)
render conn, "edit.html", changeset: changeset, topic: topic
end
model:
defmodule Discuss.Topic do
use Discuss.Web, :model
schema "topics" do
field :title, :string
end
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:title])
|> validate_required([:title])
end
I think I may have done something wrong in the controller edit function, but for the life of me I can’t figure out what. Any help appreciated. Thanks!
In any case, if someone could make the error here a little less ambiguous, I’m sure that would help to. Thanks!