On 10/7/05, Belorion <belorion-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''m working with a legacy db with a table name
"image_cache".
>
> class ImageCache < ActiveRecord::Base
> set_table_name :image_cache
> end
>
> I can set the table name just fine as above, but there is still a
> pluralizatoin issue becuase I have another model that has a
''has_many''
> relationship to ImageCache. I use "has_many :imagescaches" but I
get an
> error because it looks for the model "ImageCach" instead of
"ImageCache".
> Is there a way to work around this? I know I can rename my model to
> something else, but I am trying to keep it as close to the underlying
> database schema as possible (because everyone I work with knows the schema
> as image_cache, not cache_image or whatever else I could come up with that
> would pluralize correctly).
>
> Is there a place I can tell it that the correct pluralization map is
> ImageCache <=> ImageCaches ? Thanks.
>
has_many :image_caches, :class_name => ''ImageCache''
The environment.rb that comes with edge rails has this in the comments:
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, ''\1en''
# inflect.singular /^(ox)en/i, ''\1''
# inflect.irregular ''person'', ''people''
# inflect.uncountable %w( fish sheep )
# end
Try that....
--
rick
http://techno-weenie.net