Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4566 > unrolled thread
| Started by | Gregory Ma <g.marcilhacy@gmail.com> |
|---|---|
| First post | 2011-05-15 09:35 -0500 |
| Last post | 2011-05-15 12:20 -0500 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.ruby
Problem with the classify method from active support Gregory Ma <g.marcilhacy@gmail.com> - 2011-05-15 09:35 -0500
Re: Problem with the classify method from active support Xavier Noria <fxn@hashref.com> - 2011-05-15 10:57 -0500
Re: Problem with the classify method from active support Gregory Ma <g.marcilhacy@gmail.com> - 2011-05-15 11:47 -0500
Re: Problem with the classify method from active support Gregory Ma <g.marcilhacy@gmail.com> - 2011-05-15 12:20 -0500
| From | Gregory Ma <g.marcilhacy@gmail.com> |
|---|---|
| Date | 2011-05-15 09:35 -0500 |
| Subject | Problem with the classify method from active support |
| Message-ID | <ae14b0c42fc1ab56ad2032593d980c96@ruby-forum.com> |
Hi,
I am create a gem and I have encounter a problem using active_support
3.x and the classify method from the Inflector module.
If i am using active_support version 2.3.x I am able to do so:
>> ActiveSupport::Inflector::classify("car")
=> Car
But in ActiveSupport 3, things have changed a little. If I am reading
correctly
the module documentation
(https://github.com/rails/rails/blob/3-0-7/activesupport/lib/active_support/inflector/inflections.rb)
it should be working like this:
>> ActiveSupport::Inflector.inflections.classify("car")
=> NoMethodError: undefined method `classify' for
#<ActiveSupport::Inflector::Inflections:0x101bb6848>
But it doesn't work... I really don't understand why I get the
NoMethodError as the method exists in the documentation and when I
autocomplete the inflections instance I have the classify method.
ps: i am not using Rails or the Rails Console
Does someone has any idea where this could come from?
GReg
--
Posted via http://www.ruby-forum.com/.
[toc] | [next] | [standalone]
| From | Xavier Noria <fxn@hashref.com> |
|---|---|
| Date | 2011-05-15 10:57 -0500 |
| Message-ID | <BANLkTi=sPDUFOkPWH6PJG3Zcy6P3HqEFhw@mail.gmail.com> |
| In reply to | #4566 |
On Sun, May 15, 2011 at 4:35 PM, Gregory Ma <g.marcilhacy@gmail.com> wrote:
> I am create a gem and I have encounter a problem using active_support
> 3.x and the classify method from the Inflector module.
>
> If i am using active_support version 2.3.x I am able to do so:
>>> ActiveSupport::Inflector::classify("car")
> => Car
>
> But in ActiveSupport 3, things have changed a little. If I am reading
> correctly
> the module documentation
> (https://github.com/rails/rails/blob/3-0-7/activesupport/lib/active_support/inflector/inflections.rb)
> it should be working like this:
>
>>> ActiveSupport::Inflector.inflections.classify("car")
> => NoMethodError: undefined method `classify' for
> #<ActiveSupport::Inflector::Inflections:0x101bb6848>
>
> But it doesn't work... I really don't understand why I get the
> NoMethodError as the method exists in the documentation and when I
> autocomplete the inflections instance I have the classify method.
>
> ps: i am not using Rails or the Rails Console
>
> Does someone has any idea where this could come from?
> GReg
The way to load Active Support changed with AS 3.0.0. I suspect your
code is loading active_support.rb, which is now really really light.
This is explained at the beginning of the Active Support Core
Extensions guide:
http://guides.rubyonrails.org/active_support_core_extensions.html#how-to-load-core-extensions
That's focused on core extensions, but if you do not want to have the
String class extended with inflection methods, the same principles
apply to non-core extensions.
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ma <g.marcilhacy@gmail.com> |
|---|---|
| Date | 2011-05-15 11:47 -0500 |
| Message-ID | <aedb1e844c2c2ce2b548df13616c118e@ruby-forum.com> |
| In reply to | #4566 |
Thanks for the tip, it's working. -- Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ma <g.marcilhacy@gmail.com> |
|---|---|
| Date | 2011-05-15 12:20 -0500 |
| Message-ID | <2ac6521c0d18a66aed4551417ef684bf@ruby-forum.com> |
| In reply to | #4566 |
Thanks again I have been able to fix this but I am encountering a new issue. If works fine with ActiveSupport 2.3.x mais but it doesn't work 3.0.x Here is the line: >> board = :ruby_forum >> klass = board.respond_to?(:classify) ? board.classify : ActiveSupport::Inflector::classify(board) >> NoMethodError: undefined method `classify' for ActiveSupport::Inflector:Module This line doesn't work in version 3 because it evaluates the last condition, and the classify method doesn't exist in version 3. What trick could I use? -- Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web