I think you have the relationships reversed. If a company can be one of many
different types, your relationships should be:
Company
belongs_to :company_type, :foreign_key => ''ctype_id''
CompanyType
has_many :companies
and your tables should be:
Company
id
...
ctype_id
Company_Types
id
ctype
...
Now you may change the value for ctype in the Company Types table and the
changes will be reflected in all the companies that reference that company
type. eg
mycompany.ctype.ctype
Hammed
On 30/11/05, Nick Ce <graphis1-ee4meeAH724@public.gmane.org>
wrote:>
> I have two classes ''Company'' and
''CompanyType''
>
> Company has_one :company_type and
> CompanyType belongs_to :company
>
> My company_type table contains a field called "ctype" - when I
modify
> this, I''d like all companies of that type to update to the new
modified
> name.
>
> Is there a way to do this with dependencies, or would anyone be kind
> enough to suggest another way?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails