Conversation
| render(conn, "new.html", changeset: changeset) | ||
| end | ||
|
|
||
| def create(conn, %{"event" => event_params}) do |
There was a problem hiding this comment.
We need a service module for events.
Events will have more things to implement, and those things can't be part of controller. Let's extract these code to a svc module and use context inside it
| field :end_date, :string | ||
| field :start_date, :string |
There was a problem hiding this comment.
these two should be utc datetime type, not strings
| {:ok, event} -> | ||
| conn | ||
| |> put_flash(:info, "Site created successfully.") | ||
| |> redirect(to: Routes.site_event_path(conn, :index, :id)) |
There was a problem hiding this comment.
redirect(to: Routes.site_event_path(conn, :index, :id))
Will this line work? Shouldn't we be passing the id of the site?
| site_id = Nudge.Accounts.get_site!(id) | ||
|
|
||
| IO.inspect(site_id) | ||
| events = Sites.list_site_events(site_id) |
There was a problem hiding this comment.
Does get_site!/1 return just id or the whole site struct with data?
This is why we end up having type casting error in the query. The query expects and id, but you are passing the whole result to the list_site_events/1
| query = | ||
| from site in Nudge.Accounts.Site, | ||
| where: site.id == ^site_id, | ||
| order_by: site.inserted_at |
There was a problem hiding this comment.
is this the right query for filtering events?
closes #9