-
Notifications
You must be signed in to change notification settings - Fork 29
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
Is there ActiveModel support? #2
Comments
Hi, oh. Sorry. Damn. ActiveModel support was removed at some point. It could probably be easily implemented again. Currently the method is only included in ActiveRecord I cant remember why it wasn't included in ActiveModel also. It might be because the way of fetching current values by I'm not sure if ActiveModel supported the same way of using array accessors. So it might need another way for activemodels e.g. https://github.com/holli/auto_strip_attributes/blob/master/lib/auto_strip_attributes.rb#L13 So yeah, no support for ActiveModels currently. If you fix it somehow and tests pass, make sure to do a Pull request :) cheers, Olli |
+1 for this. |
Any update on this? - I would like to use this with Mongoid which uses ActiveModel |
|
It's not automatic, but it seems like it is possible to get AutoStripAttributes to work with ActiveModel as-is. As long as you:
It must work because that's what the test suite does in order to mock Active Record: https://github.com/holli/auto_strip_attributes/blob/master/test/auto_strip_attributes_test.rb#L19-L32 ...though it may not be widely recommended. I'd like to contribute some help to this issue. Would it be better for me to submit a PR to add the process to the docs, or for me to work on the test suite to move #8 forward so that we can automatically extend ActiveModel classes? |
True, good note. Why would you think it might not be widely recommended? (I havent thought about it in a while so...) Tests in that branch/pr would be nice. It just needs another test case that uses activemodel instead of activerecord so that all cases of https://github.com/holli/auto_strip_attributes/pull/8/files#diff-e020ef2416f83368a5ae745bf7867082R12 are tested. .. and ofcours docs updated :) |
+1 for activemodel usage... |
Hi,
Great work on your gem. Your docs referenced that it supports ActiveModel, but I didn't see any examples provided on how to do this. Here I have a simple ActiveModel class:
Here's what I put in my Gemfile:
But when I fire up the Rails console, I get this:
I've verified that this gem is installed here:
Would you be able to provide an example of how to get this to work with ActiveModel? If I figure this out, I'll submit a Pull Request with an example. Thanks for your help!
Chip
The text was updated successfully, but these errors were encountered: