Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activemodel (support for other mappers like mongoid)? #7

Closed
sanford opened this issue Aug 20, 2010 · 5 comments
Closed

activemodel (support for other mappers like mongoid)? #7

sanford opened this issue Aug 20, 2010 · 5 comments

Comments

@sanford
Copy link

sanford commented Aug 20, 2010

Seems like this would be a great addition to activemodel for Rails3 so it could be used across other database mappers (mongoid, mongo_mapper, datamapper).

I'd love to use it with mongoid right now. How easy would a port be?

@dejan
Copy link
Owner

dejan commented Aug 22, 2010

I think you can use it right away. One way is to use auto_html method that is available in any object that includes AutoHtml module. You'd only have to implement before_save if you want to cache result.

Other (not sure if it will work) is to include AutoHtmlFor module (if you want auto_html_for method) in non AR model which uses only before_save callback and read/write attribute methods so I guess it should work with mongoid.

Please let me know of the result if you try that out.

@ebeigarts
Copy link
Contributor

Currently auto_html has activerecord as runtime dependancy.
I have fixed this here.

Working mongoid example:

class Post
  include Mongoid::Document
  include AutoHtmlFor

  field :body

  auto_html_for :body do
    link
  end
end

@dejan
Copy link
Owner

dejan commented Apr 12, 2011

Thanks! I've included the fix, and added your example to readme.

@dejan dejan closed this as completed Apr 12, 2011
@ebeigarts
Copy link
Contributor

Great! In the readme you should change the title from "Non-ActiveModel models" to "Non-ActiveRecord models"

@dejan
Copy link
Owner

dejan commented Apr 12, 2011

Good catch, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants