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
gem "auto_strip_attributes", "~> 2.0.2"
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
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!