Hi all, I want to get all association methods in one single model.... Any default method is provided by Active Record ??? i am using ruby 1.9.3 and rails 3.1.3 Please reply me .... Thanks, kingston.s -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 17 January 2012 06:41, Kingston.s <jenorish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > > I want to get all association methods in one single model....What do you mean "get" the methods? Colin> > Any default method is provided by Active Record ??? > > i am using ruby 1.9.3 and rails 3.1.3 > > Please reply me .... > > > Thanks, > > kingston.s > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- gplus.to/clanlaw -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Jan 17, 2012 at 7:41 AM, Kingston.s <jenorish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > > I want to get all association methods in one single model.... > > Any default method is provided by Active Record ??? > > i am using ruby 1.9.3 and rails 3.1.3 >User.reflect_on_all_associations.map{|a| [a.macro,a.name]} etc. Peter -- Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 17, 7:08 pm, Peter Vandenabeele <pe...-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> wrote:> On Tue, Jan 17, 2012 at 7:41 AM, Kingston.s <jenor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > > > I want to get all association methods in one single model.... > > > Any default method is provided by Active Record ??? > > > i am using ruby 1.9.3 and rails 3.1.3 > > User.reflect_on_all_associations.map{|a| [a.macro,a.name]} > > etc. > > Peter > > -- > Peter Vandenabeelehttp://twitter.com/peter_vhttp://rails.vandenabeele.comHi Peter, Thanks for quick reply.. This is working fine.but it is return all the association and the corresponding model name.... like [:has_many, :site_users] but i want association methods like site_user_ids and site_user_ids kingston.s -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Jan 18, 2012 at 5:49 AM, Kingston.s <jenorish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 17, 7:08 pm, Peter Vandenabeele <pe...-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> wrote: > > On Tue, Jan 17, 2012 at 7:41 AM, Kingston.s <jenor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all, > > > > > I want to get all association methods in one single model.... > > > > > Any default method is provided by Active Record ??? > > > > > i am using ruby 1.9.3 and rails 3.1.3 > > > > User.reflect_on_all_associations.map{|a| [a.macro,a.name]} > > > > etc. > > > > Peter > > > > -- > > Peter Vandenabeelehttp:// > twitter.com/peter_vhttp://rails.vandenabeele.com > > Hi Peter, > > Thanks for quick reply.. > > This is working fine.but it is return all the association and the > corresponding model name.... > > like [:has_many, :site_users] > > but i want association methods like site_user_ids and site_user_ids>Hmmm, I don''t see them in that datastructure. I presume they are defined automatically, based on the name of the association, in this code starting at: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/builder/collection_association.rb#L57 In general ... I think it is better not to touch the _id fields manually and use other association methods (without _id) if possible. E.g. the ''build'' or ''delete'' functions on the has_many association. HTH, Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Reasonably Related Threads
- Saving without callbacks in Rails 3
- why doesn't an instance of Object get Class's new instance method?
- Error while rake actions
- Create Two objects at the same time
- DEPRECATION WARNING: Passing a template handler in the template name is deprecated. (rspec + haml)