I have found a few posts on various sites that this was something that was going to be available. The posts were all over a year ago, but it doesn''t seem like it is available in 1.2 unless I am missing something (which I hope is true) I have a member and office table that each have an address. Any advice on the best way to do this. I have also seen a few posts saying to use delegates, but without much info on how to do so and I can''t find any info on delegates in the docs. Any advice on the best way to make these relationships is appreciated. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 2, 10:03 am, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have found a few posts on various sites that this was something that > was going to be available. The posts were all over a year ago, but it > doesn''t seem like it is available in 1.2 unless I am missing something > (which I hope is true) > > I have a member and office table that each have an address. Any > advice on the best way to do this. I have also seen a few posts > saying to use delegates, but without much info on how to do so and I > can''t find any info on delegates in the docs. > > Any advice on the best way to make these relationships is appreciated. > > Thanksare these the posts youre talking about? http://railsexpress.de/blog/articles/2006/09/16/piggy-back-plugin-updated http://www.artofmission.com/articles/2007/6/21/has_one-through http://entren.ivanyvenian.com/inclusiones-anidadas-asociaciones/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
first 2 yes, last one no. On Nov 2, 12:10 pm, gene tani <gene.t...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 2, 10:03 am, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have found a few posts on various sites that this was something that > > was going to be available. The posts were all over a year ago, but it > > doesn''t seem like it is available in 1.2 unless I am missing something > > (which I hope is true) > > > I have a member and office table that each have an address. Any > > advice on the best way to do this. I have also seen a few posts > > saying to use delegates, but without much info on how to do so and I > > can''t find any info on delegates in the docs. > > > Any advice on the best way to make these relationships is appreciated. > > > Thanks > > are these the posts youre talking about?http://railsexpress.de/blog/articles/2006/09/16/piggy-back-plugin-upd...http://www.artofmission.com/articles/2007/6/21/has_one-throughhttp://entren.ivanyvenian.com/inclusiones-anidadas-asociaciones/--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
if I take the long approach of creating a get and set method, is there a short way to make the association between the address and member table without having to create a model out of the associative table? class member ... #properties def address if @address.nil? @address = Address.find_by_member_id(self.id) unless @address.nil? @address end def address=(value) @address = value end #methods def after_insert @address.save #connect the tables here end ... end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
or there is this way, but now I have a address collection within the model. It is rather difficult to believe that Rails would not have a better way of making associations of this sort. class Member has_and_belongs_to_many :addresses, :join_table => :members_addresses #properties def address return self.addresses[0] unless self.addresses.nil? nil end def address=(value) self.addresses = [] if self.addresses.nil? self.addresses << value end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
the guy who wrote the second article reference, Ryan Heneise, is working on a patch for Rails to add the has_one :through. On Nov 2, 3:23 pm, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> or there is this way, but now I have a address collection within the > model. It is rather difficult to believe that Rails would not have a > better way of making associations of this sort. > > class Member > has_and_belongs_to_many :addresses, :join_table > => :members_addresses > > #properties > def address > return self.addresses[0] unless self.addresses.nil? > nil > end > > def address=(value) > self.addresses = [] if self.addresses.nil? > self.addresses << value > end > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In my case I have an address table that is linked to a few tables within the database. It turns out that in my case polymorphic association is probably the best bet anyway. Thanks for letting me know though, I am sure the plugin will come in handy someday. On Nov 3, 9:08 am, Robert <RobertREv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> the guy who wrote the second article reference, Ryan Heneise, is > working on a patch for Rails to add the has_one :through. > > On Nov 2, 3:23 pm, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > or there is this way, but now I have a address collection within the > > model. It is rather difficult to believe that Rails would not have a > > better way of making associations of this sort. > > > class Member > > has_and_belongs_to_many :addresses, :join_table > > => :members_addresses > > > #properties > > def address > > return self.addresses[0] unless self.addresses.nil? > > nil > > end > > > def address=(value) > > self.addresses = [] if self.addresses.nil? > > self.addresses << value > > end > > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---