Form with references field
I have a form with references field:
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name %>
<%= form.label :city_id_id, style: "display: block" %>
<% cities_array = City.all.map { |city| [city.name, city.id] } %>
<%= select_tag :cities_array, options_for_select(cities_array) %>
But this error is showing after send form:
ActiveRecord::StatementInvalid in EntitiesController#create
SQLite3::SQLException: no such table: main.city_ids
Hey there,
The error you're encountering, "SQLite3::SQLException: no such table: main.city_ids," suggests that there might be an issue with the database table name. Check if you're referencing the correct table name, which should be "cities" instead of "city_ids" in your code. Double-check your database schema and table names to make sure they match. ๐ ๏ธ๐๏ธ๐
Hello,
Yes, I checked the database and saw that my error was when I generated the model, putting the city_id:references field instead of just city:references.
Thanks