On 14 August 2010 16:05, Ze Ca <li...@ruby-forum.com> wrote:
> Chris Mear wrote:
>> On 14 August 2010 07:23, Ze Ca <li...@ruby-forum.com> wrote:
>>>
>>> `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
>
> Thank you for the reply. putting the include  under the model class,
> which worked! Thanks very much for that.
>
> In my script/console, I tried instantiating a new "Sellers" object
> (Sellers is one of the types of edit distance methods), with this code:
>
>
>>> m = Sellers.new("hello")
>
> but still got the same error output.
>
> however, I created a new object of my model, Responses:
>
> x = Responses.new
>
> after which I was able to create an amatch Sellers object within a
> function:
>
> def title_must_have_changed_by_one_letter
>    m = Sellers.new(first_response)
>    errors.add_to_base("Sorry,  the last submitted response must have
> changed by one letter") if m.match(second_response)     != 1.0
> end
>
> That makes sense to me. I'm just curious why I wasn't able to make a new
> Sellers object in the first page?

Did you restart or reload your console after making the change to
seller.rb? Sometimes there are changes that the console doesn't pick
up until you reload it.

Chris

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to