skanel
I am trying to create blog with phoenix for learning purpose , but just follow the tutorial,here Building a Blog with Phoenix - Playing With Fire
but this blog is using the older version of deps, I am on the final step but facing error, anyone please give me some advice and how to fix it .
article_view.ex
defmodule Pxblog.ArticleView do
use Pxblog.Web, :view
use Timex
def list_date_format(date, format_string \ “%B %d, %Y”) do
<< Ecto.Date.to_iso8601(date) <> “T00:00:00Z” >>
|> DateFormat.parse!(“{ISOz}”)
|> DateFormat.format!(format_string, :strftime)
end
end
post_view.ex
defmodule Pxblog.PostView do
use Pxblog.Web, :view
use Timex
def publish_status(true), do: "Published"
def publish_status(_), do: "Draft"
def date_format(date), do: date_format date, "%d %b %Y"
def date_format(date = %Ecto.DateTime{}, format_string) do
Ecto.DateTime.to_iso8601(date)
|> date_formatter(format_string)
end
def date_format(date = %Ecto.Date{}, format_string) do
<< Ecto.Date.to_iso8601(date) <> "T00:00:00Z" >>
|> date_formatter(format_string)
end
def date_format(_, _format), do: ""
defp date_formatter(date, format_string) do
date
|> DateFormat.parse!("{ISOz}")
|> DateFormat.format!(format_string, :strftime)
end
end
mix.exs
defp deps do
[
{:phoenix, “~> 1.3.0-rc”},
{:phoenix_pubsub, “~> 1.0”},
{:phoenix_ecto, “~> 3.2”},
{:postgrex, “>= 0.0.0”},
{:phoenix_html, “~> 2.10”},
{:phoenix_live_reload, “~> 1.0”, only: :dev},
{:gettext, “~> 0.11”},
{:cowboy, “~> 1.0”},
{:earmark, “~> 0.1”},
{:timex, “~> 3.1”} # BUT in tutorial is using 0.19
]
end
My error
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming












Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Are you on Ecto 2.1+?
kokolegorille
You should update phoenix to 1.3.0, not the release candidate
skanel
Oh I see I am using Ecto V2.2
skanel
still the same error
kokolegorille
I have the same error doing the same command… so it must be ~D[2017-09-01] not seen as a date.
OvermindDL1
You cannot use a non-Ecto.Date with it in to_string without casting it first. So
~D[2017-09-01] |> Ecto.Date.cast() |> Ecto.Date.to_string().Why are you using
Ecto.Dateanyway? In Ecto if you use the:datetype it uses Elixir’s Date instead of Ecto’s date and it works just all around better.kokolegorille
The blog post is old and use phoenix 1.1.4. Old post might not work with newer phoenix version.
BTW Ecto.Date is deprecated https://hexdocs.pm/ecto/Ecto.Date.html#content