Search code examples
ruby-on-railsmongoidmongoid4

How can I use form objects with mongoid in Rails 4


With Active record I can do the following to get form object.

Rails 3

class TestForm
 extend ActiveModel::Naming
 include ActiveModel::Conversion
 include ActiveModel::Validations

 def persisted?
  false
 end
end

Rails 4

class TestForm
 include  ActiveModel::Model
end

but how can I acheive the same with Mongoid 4?


Solution

  • Look at this https://github.com/apotonick/reform

    Reform provides the following Mongoid specific features. They're mixed in automatically in a Rails/Mongoid setup.