Skip to content

MongoDB booleans #635

rutte opened this Issue Jul 26, 2012 · 7 comments

6 participants

rutte commented Jul 26, 2012

MongoDB Boolean fields (which are of type Boolean) renders text field instead of checkbox.

Must confess I have only tried with the Mongoid wrapper.


We don't support MongoID integration in SimpleForm, but I'll be glad to accept a pull request to make this work.

@rafaelfranca rafaelfranca reopened this Jul 30, 2012

@rutte would you mind sharing the model you're using with SimpleForm, and the form code? This would help us or someone else to work on this. Thanks.

xanview commented Sep 2, 2012

I'm using default scaffolds, my model looks like this:

class Event
  include Mongoid::Document
  field :complete, type: Boolean, default: false

My view looks like this:

= simple_form_for(@scope) do |f|
  = f.error_notification

    = f.input :complete

    = f.button :submit

The :complete field is rendered as a textfield instead of the expected checkbox for boolean.


Since we don't support Mongoid we can't discovery what kind is the field. You have to pass the type using the :as option.

nashby commented Nov 7, 2012

@rafaelfranca I was thinking about using orm_adapter to solve this issue. Unfortunately it doesn't support column_type or similar method so I was going to add it. Do you think its worth it? Or we don't need another dependency?


I don't think is worth right now since you can use the :as options. Maybe in the future we can support mongoid.


Dirty patch to Mongoid::Document

module Mongoid
  module Document
    ARFakeColumn =, :limit, :number?)

    def column_for_attribute(attribute_name)
      if fields[attribute_name.to_s].options[:type] == Mongoid::Boolean, 0)
      else, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.