formtastic-bootstrap icon indicating copy to clipboard operation
formtastic-bootstrap copied to clipboard

as: :select unrecognized input on non-model form when using PostgreSQL

Open sam0x17 opened this issue 9 years ago • 11 comments

EDIT: turns out it had nothing with moving to postgresql --- I ran bundle update and that pushed formtastic to 3.0.0, which is what broke everything. See https://github.com/mjbellantoni/formtastic-bootstrap/issues/109#issuecomment-56828388 for solution

I had a form that was working perfectly when I was using SQLite. I moved to PostgreSQL and for some reason this broke formtastic-bootstrap's ability to recognize :select as an input type.

Formtastic::UnknownInputError - "Unable to find input class for select"

To reproduce this error try the following:

$ rails new select-error-app --database=postgresql
$ rails g scaffold Post title:string body:text
$ rake db:create
$ rake db:migrate
$ rake db:setup

Add the following to the top of the auto-generated app/views/posts/index.html.erb file:

<%= semantic_form_for 'filter_form' do |f| %>
  <%= f.input :test, as: :select, collection: {"item 1" => 1, "Item 2" => 2, "Item 3" => 3} %>
  <%= f.actions %>
<% end %>

Add the required styles and gem files etc for formtastic-bootstrap

Now run rails server

$ rake rails server

Navigate to http://localhost:3000 in your web browser. You should now get the same error I'm getting.

This is a model-less form, which is supported according to the formtastic documentation as long as you specify an "as:" for each input.

As far as I can tell this will not throw the same error if you use SQLite.

What could be causing this error?

sam0x17 avatar Sep 24 '14 19:09 sam0x17