holli/auto_strip_attributes — Issue #2: Is there ActiveModel support
Author: chip
Created: 2011-11-30 02:13:44+00:00
State: open

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:
```
require 'active_model'

class ProductSearch
include ActiveModel::Validations

validates_length_of :keyword, :minimum => 1, \
:message => "must be at least 1 character."
attr_accessor :keyword
auto_strip_attributes :keyword

def results
puts "results keyword=#{@keyword}"
@results ||= Solr.search(@keyword)
end
end
```

Here's what I put in my Gemfile:
```
gem "auto_strip_attributes", "~> 1.0"
```

But when I fire up the Rails console, I get this:
```
ruby-1.8.7-p352 :003 > p = ProductSearch.new
NoMethodError: undefined method `auto_strip_attributes' for ProductSearch:Class
from /Users/chip/code/rentwb/app/models/products/product_search.rb:17
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:454:in `load'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:454:in `load_file'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:453:in `load_file'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:340:in `require_or_load'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:487:in `load_missing_constant'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:183:in `const_missing'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:181:in `each'
from /Users/chip/code/rentwb/vendor/bundle/ruby/1.8/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:181:in `const_missing'
from (irb):3
```

I've verified that this gem is installed here:
```
vendor/bundle/ruby/1.8/gems/auto_strip_attributes-1.1/lib/auto_strip_attributes.rb
```

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