On 11/24/07, Scott <[EMAIL PROTECTED]> wrote:
>
> It looks like the ActiveRecord and generators namespace conventions
> are inconsistent. Sometimes the model's table name defaults to
> 'module_classname' and sometimes to just 'classname.' I'm happy to
> submit patches and tests, but what is the preferred default?
>
> Example: /script/generate model -t carnivores/tiger name:string
>
> Generator uses table_name 'carnivores_tigers' for fixtures and
> migrations
> Base#table_name defaults to 'tigers'
> Base#table_name rdoc say 'carnivores_tigers'
>
> Granted, this can be fixed by explicitly setting the table name in the
> model class, but this doesn't seem right.
If the parent is a module, it uses a normal table name.
module Foo
class Bar < ActiveRecord::Base
puts table_name # => 'bars'
end
end
class Foo < ActiveRecord::Base
class Bar < ActiveRecord::Base
puts table_name # => 'foo_bars'
end
end
I don't know if the generator should be updated, or maybe the docs
just need to be clarified a bit.
--
Rick Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
--~--~---------~--~----~------------~-------~--~----~
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 [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-core?hl=en
-~----------~----~----~----~------~----~------~--~---