class AbstractBase < ActiveRecord::Base
self.abstract_class = true
end
class Foo < AbstractBase
self.table_name = 'footable'
end
class Bar < AbstractBase
self.table_name = 'bartable'
end
you may not need to set the table_name if the class names map to rails
conventions but just in case you need to do it that way.
Or;
module SharedStuff
all your common code amongst the models
end
class Foo < ActiveRecord::Base
include SharedStuff
end
class Bar < ActiveRecord::Base
include SharedStuff
end
either should achieve the same end.
James McCarthy
[EMAIL PROTECTED]
On 25 Feb 2008, at 23:44, Lucas Campbell wrote:
>
> Is there a way to use one model to write to different tables if all of
> the tables have the same fields and attributes?
>
> I would like to use one model but be able to decide which table it
> accesses.
>
> Anyone know if this is possible?
> --
> Posted via http://www.ruby-forum.com/.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Deploying Rails" 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-deployment?hl=en
-~----------~----~----~----~------~----~------~--~---