How do you increase Characters in a text box?

I am not sure You want to store a date…

In fact, it looks like a duration. I would use integer, to express seconds, or any units for a period.

What You need is a good function to transform this unit into something human readable. (HH:MM:SS)

But if it is really a date, use a date field, and the appropriate input.

New error

[error] #PID<0.515.0> running DishOutWeb.Endpoint (connection #PID<0.514.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: POST /delish_foods
** (exit) an exception was raised:
    ** (Postgrex.Error) ERROR 22001 (string_data_right_truncation) value too long for type character varying(255)

I think Ecto doesn’t allow to input anything over 255

It does… I have been using binary fields for description, or long text since I started using Phoenix and Ecto.

Did You reset the database after making change to fields? It’s not enough to just change the value. In particular when You change migrations.

As far as I know, in the migration table it is:

add(:description, :text)

add(:publication_date, :date)

and in the schema it is:

field(:description, :string)

field(:publication_date, :date)

Then in the form it is:

<%= text_input f, :description %>

<%= date_select f, :publication_date %>

This is wrong, :string type in schema has no length limit. The type should be :text in migration and :string in schema.

I think this is the issue. You have originally created the DB with a character varying type with 255 limit and have not rolled back that migration, so the DB type has not been changed.

I use binary, instead ot string and text…

It is also working :slight_smile:

1 Like