On Sun, May 3, 2009 at 6:09 AM, Fresh Mix
<[email protected]>wrote:

>
> In irb all works fine:
>
> # irb
> irb(main):001:0> require 'rubygems'
> => true
> irb(main):002:0> require 'raspell'
> => true
> irb(main):003:0> speller = Aspell.new("ru_RU")
> => #<Aspell:0x7f8692c9d158>
> irb(main):004:0> speller.suggestion_mode = Aspell::NORMAL
> => "normal"
> irb(main):005:0> speller.check("лошадь")
> => true
>
> But same in Rails project:
>
> require 'rubygems'
> require 'raspell'
>
> def xxx
>  speller = Aspell.new("ru_RU")
>  speller.suggestion_mode = Aspell::NORMAL
>  @xxx = speller.check("лошадь").to_s
> end
>
> @xxx is false! Why?


In Ruby, when one tries to access an instance variable directly, which is
always private by default, the return value is nil until it has been
properly initialized.  You can access instance variables using an accessor
on a class.  In any case, I recommend that you get a copy of "Programming
Ruby" or "Programming Ruby 1.9" and read the section on "Scope of Constant
and Variables".

Good luck,

-Conrad

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to