Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoid and simple_form, Boolean type does not create checkbox

I'm starting with mongoid and simple_form. If I have a model with :type => Boolean and render it in a (haml) view with =f.input, it creates a text input field not a checkbox.

The doc says that boolean maps to a checkbox but I suspect that Boolean and boolean are not handled the same.

I can work around with adding :as => boolean to the simple_form.

1) Is that expected or am I doing something wrong? 2) Is there a way to add a general mapping of Boolean to simple_form? 3) Should I generate an issue for simple_form to correct this?

Thanks in advance.

like image 551
Scott Eisenberg Avatar asked Jun 22 '12 15:06

Scott Eisenberg


1 Answers

Unfortunately, simple_form does not currently work "automatically" with Mongoid. You have to specify the as: :boolean.

There have been indications that people want Mongoid integration, but I don't think that it has happened yet. So, why not give it a shot? Here are some relevant tickets from the issue tracker:

  • https://github.com/plataformatec/simple_form/issues/635
  • https://github.com/plataformatec/simple_form/pull/281
  • https://github.com/plataformatec/simple_form/pull/153
like image 188
David J. Avatar answered Nov 24 '22 02:11

David J.