Using Rails 3.0.5 is it expected that ruby-1.8.7-p302 > "KnownIP".tableize => "known_ips" rather than "known_i_ps" as I had expected? The result (at least I think it is the result of above) is that rails g model KnownIP provides a model class KnownIp in known_ip.rb, rather than KnownIP in known_i_p.rb Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Did your rails g generate the KnownIP model or the KnownIp model? Your post says both. On 04/04/2011, at 0:20, Colin Law <clanlaw@googlemail.com> wrote:> Using Rails 3.0.5 is it expected that > ruby-1.8.7-p302 > "KnownIP".tableize > => "known_ips" > rather than "known_i_ps" as I had expected? > > The result (at least I think it is the result of above) is that > rails g model KnownIP > provides a model class KnownIp in known_ip.rb, rather than KnownIP in > known_i_p.rb > > Colin > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 3 April 2011 21:21, Ryan Bigg <radarlistener@gmail.com> wrote:> Did your rails g generate the KnownIP model or the KnownIp model? Your post says both.Oh, are you sure it says both?> On 04/04/2011, at 0:20, Colin Law <clanlaw@googlemail.com> wrote: >> ... >> The result (at least I think it is the result of above) is that >> rails g model KnownIP >> provides a model class KnownIp in known_ip.rb, rather than KnownIP in >> known_i_p.rbIt produced a KnownIp model when one might expect it to produce KnownIP. Having investigated further I am pretty sure the problem is in ActiveSupport::Inflector#underscore, giving ruby-1.8.7-p302 > ActiveSupport::Inflector.underscore("KnownIP") => "known_ip" ruby-1.8.7-p302 > ActiveSupport::Inflector.underscore("KnownIP").camelize => "KnownIp" However looking at the intro on [1] I see "The Rails core team has stated patches for the inflections library will not be accepted in order to avoid breaking legacy applications which may be relying on errant inflections. If you discover an incorrect inflection and require it for your application, you’ll need to correct it yourself (explained below)." So this may be a case of "that is just how it is". Colin [1] http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
It also says, in the docs you linked to: As a rule of thumb you can think of underscore as the inverse of camelize, though there are cases where that does not hold: "SSLError".underscore.camelize # => "SslError" So the situation you''re talking about is a known shortcoming. Allen Madsen http://www.allenmadsen.com On Sun, Apr 3, 2011 at 5:08 PM, Colin Law <clanlaw@googlemail.com> wrote:> On 3 April 2011 21:21, Ryan Bigg <radarlistener@gmail.com> wrote: > > Did your rails g generate the KnownIP model or the KnownIp model? Your > post says both. > > Oh, are you sure it says both? > > > On 04/04/2011, at 0:20, Colin Law <clanlaw@googlemail.com> wrote: > >> ... > >> The result (at least I think it is the result of above) is that > >> rails g model KnownIP > >> provides a model class KnownIp in known_ip.rb, rather than KnownIP in > >> known_i_p.rb > > It produced a KnownIp model when one might expect it to produce > KnownIP. Having investigated further I am pretty sure the problem is > in ActiveSupport::Inflector#underscore, giving > > ruby-1.8.7-p302 > ActiveSupport::Inflector.underscore("KnownIP") > => "known_ip" > ruby-1.8.7-p302 > ActiveSupport::Inflector.underscore("KnownIP").camelize > => "KnownIp" > > However looking at the intro on [1] I see > "The Rails core team has stated patches for the inflections library > will not be accepted in order to avoid breaking legacy applications > which may be relying on errant inflections. If you discover an > incorrect inflection and require it for your application, you’ll need > to correct it yourself (explained below)." > So this may be a case of "that is just how it is". > > Colin > > [1] http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 3 April 2011 22:21, Allen Madsen <allen.c.madsen@gmail.com> wrote:> It also says, in the docs you linked to: > > As a rule of thumb you can think of underscore as the inverse of camelize, > though there are cases where that does not hold: > > "SSLError".underscore.camelize # => "SslError" > > So the situation you''re talking about is a known shortcoming.That is true, thanks. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Apr 3, 10:08 pm, Colin Law <clan...@googlemail.com> wrote:> > However looking at the intro on [1] I see > "The Rails core team has stated patches for the inflections library > will not be accepted in order to avoid breaking legacy applications > which may be relying on errant inflections. If you discover an > incorrect inflection and require it for your application, you’ll need > to correct it yourself (explained below)." > So this may be a case of "that is just how it is". >Although a change to the inflections was made not too long ago ( https://github.com/rails/rails/commit/e925acb8 ) Fred> Colin > > [1]http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 5 April 2011 13:11, Frederick Cheung <frederick.cheung@gmail.com> wrote:> > > On Apr 3, 10:08 pm, Colin Law <clan...@googlemail.com> wrote: >> >> However looking at the intro on [1] I see >> "The Rails core team has stated patches for the inflections library >> will not be accepted in order to avoid breaking legacy applications >> which may be relying on errant inflections. If you discover an >> incorrect inflection and require it for your application, you’ll need >> to correct it yourself (explained below)." >> So this may be a case of "that is just how it is". >> > > Although a change to the inflections was made not too long ago > ( https://github.com/rails/rails/commit/e925acb8 )Yes, I noticed that in the other thread. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.