[Rails] rename associations

Michael Koziarski koziarski at gmail.com
Tue Mar 1 23:12:11 GMT 2005


On Tue, 01 Mar 2005 15:49:50 -0600, John-Mason P. Shackelford
<john-mason at shackelford.org> wrote:
> Greetings all,
> 
> In looking at the API for ActiveRecord::Associations::ClassMethods there
> doesn't appear to be a way to rename an association. In doing some
> refactoring I am replacing one table with two but want to preserve the
> old associations names, e.g. I want to be able to still say
> build_type.artifacts instead of having to use the new table name:
> build_type.build_type_artifacts. Is an alias my only option or am I
> missing something glaringly obvious?

No,  it's a little confusing at first.  But I think the functionality
you're looking for is there.

class BuildType < ActiveRecord::Base
  has_and_belongs_to_many :anynameyouwant, :classname=>"Artifact"
end


> John-Mason Shackelford
> 
> Software Developer
> Pearson Educational Measurement
> 
> 2510 North Dodge St.
> Iowa City, IA 52245
> ph. 319-354-9200x6214
> john-mason.shackelford at pearson.com
> http://pearsonedmeasurement.com
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
> 


-- 
Cheers

Koz


More information about the Rails mailing list