small medium large xlarge

01 Jan 2016, 11:45
Sven Riedel (8 posts)

I’m working through the B6 version of the book and am currently in the chapter “Ecto and Changesets”.

After adding the alert messages to the web/templates/user/new.html.eex, and trying to send off the form with a username that is too long, I get the exception

    ** (FunctionClauseError) no function clause matching in Phoenix.HTML.Safe.Tuple.to_iodata/1
        (phoenix_html) lib/phoenix_html/safe.ex:72: Phoenix.HTML.Safe.Tuple.to_iodata({"should be at most %{count} character(s)", [count: 20]})

It looks like the message-tuple gets confused with the { :safe, string }-Tuple that Phoenix.HTML.Safe expects. Changing the template code to:

<%= for  {attr, message} <- f.errors do %>
  <li><%= humanize attr %> <%= translate_error message %>
<% end %>

makes everything work again.

02 Jan 2016, 12:44
Andreas Tasch (2 posts)


yes, I ran into the same problem, and found this post, pointing to phoenix 1.1.0 introducing that breaking change.

Did you also post this to the errata? Maybe the authors check that there more frequently.

03 Jan 2016, 09:10
Sven Riedel (8 posts)

Not yet; I had looked for the Errata link on the Book page (where it used to be in the old pragprog layout) and didn’t see it here in the forums. Will do now.

24 Aug 2017, 21:52
Gregory Fodor (1 post)

Small thing that distracted me in the book (and may be a bit pedantic) – it’s emphasized in more than one place during chapter 6 and 7 that relational databases are called relational because they are built to manage relationships between data.

This is a common misconception, but the reason RDBMSes are called relational is because they are built upon relational algebra, which itself is called relational because it is the algebra for the manipulation of tuples of data in sets that are called relations. The use of the term “relation” I believe is arbitrary and just the name given to these specific categories of sets under this algebra.

Not to detract from an otherwise amazing book for an amazing framework, but folks with a more formal database background may wince at these places in the book that mis-define this term.

You must be logged in to comment