Ask A Question

Notifications

You’re not receiving notifications from this thread.

Form with references field

Christian Herber Santos asked in Rails

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
Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.