On 14 August 2010 07:23, Ze Ca <[email protected]> wrote: > Hi, > > I'm trying to use the amatch gem (http://flori.github.com/amatch/) to > help with some validations. In the documentation examples > (http://flori.github.com/amatch/doc/index.html > ), after the require 'amatch', there's an include Amatch. > > Where would I put this include? I tried putting it at the very top of my > model file, but when I opened up the rails console, and tested it out > using: > > m = Sellers.new("hello") > > I get this output: > > NameError: uninitialized constant Sellers > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in > `load_missing_constant' > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in > `const_missing' > from > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in > `const_missing' > from (irb):1 > > I put the gem in my environment.rb file as well. Any help is > appreciated!
'include' statements usually go inside a class -- essentially, 'include Amatch' adjusts the class you're defining by adding the methods from the Amatch module. A 'require' statement, on the other hand, just tells Ruby to bring in the contents of the filename you specify. So you probably want this kind of thing: require 'amatch' class Seller include Amatch # Rest of your class definition here end Try that and see if it resolves the error. If not, there may be a problem finding the amatch file itself. Chris Try -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

