On 3 April 2011 14:05, Colin Law <[email protected]> wrote: > ... > It appears that this may be the technique rails uses, first to get the > table name from the model in the generate command String#tableize is > used, then singularize is used on this to get the file name, and then > camelize to get the class name, so > > ruby-1.8.7-p302 > "KnownIP".tableize > => "known_ips" > ruby-1.8.7-p302 > "KnownIP".tableize.singularize.camelize > => "KnownIp" > > Since tableize uses ActiveSupport::Inflector.tableize it may be > possible to override this for particular cases.
I think it is actually String#underscore that is causing the problem (this is called by tableize) ruby-1.8.7-p302 > "KnownIP".underscore => "known_ip" The source of this can be seen at http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore At the head of this file is a statement that the rules will not be changed as this could cause existing apps to fail, which makes sense. I do not know how to override this for special cases (or if it is possible other than monkey patching). My suggestion in the earlier post to manually create the model file and call the model what you want, while using set_table_name may well be the solution. Colin > > Colin > -- 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.

