Hi, My models: #StatusMessage model *class StatusMessage < ActiveRecord::Base belongs_to :users default_scope :order => "created_at DESC" end* #User Model *class User < ActiveRecord::Base has_many :statue_messages end *In controller I want to join these two tables. When I use : *@status = User.joins(:status_messages)* It generate an error Association named ''status_messages'' was not found; perhaps you misspelled it? How can I fix this? - Sayuj Othayoth -- 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 Aug 6, 11:21 am, Sayuj Othayoth <sayujothay...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > My models: > > #StatusMessage model > *class StatusMessage < ActiveRecord::Base > belongs_to :users > default_scope :order => "created_at DESC" > end* > > #User Model > *class User < ActiveRecord::Base > has_many :statue_messages > end > > *In controller I want to join these two tables. > When I use : > *@status = User.joins(:status_messages)* > > It generate an error > > Association named ''status_messages'' was not found; perhaps you misspelled it? > > How can I fix this?It looks like you misspelled your association - your has_many doesn''t match what you''ve passed to User.joins Fred> > - > Sayuj Othayoth-- 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.
Try: has_many :StatueMessages instead of: * has_many :statue_messages* On Sat, Aug 6, 2011 at 1:58 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Aug 6, 11:21 am, Sayuj Othayoth <sayujothay...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > My models: > > > > #StatusMessage model > > *class StatusMessage < ActiveRecord::Base > > belongs_to :users > > default_scope :order => "created_at DESC" > > end* > > > > #User Model > > *class User < ActiveRecord::Base > > has_many :statue_messages > > end > > > > *In controller I want to join these two tables. > > When I use : > > *@status = User.joins(:status_messages)* > > > > It generate an error > > > > Association named ''status_messages'' was not found; perhaps you misspelled > it? > > > > How can I fix this? > > It looks like you misspelled your association - your has_many doesn''t > match what you''ve passed to User.joins > > Fred > > > > - > > Sayuj Othayoth > > -- > 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. > >-- 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.
Thank you I misspelled *has_many :status_messages* thank you very much On Sat, Aug 6, 2011 at 2:40 PM, tudor cornea <tudor.cornea-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try: > > has_many :StatueMessages instead of: > > * has_many :statue_messages* > > > On Sat, Aug 6, 2011 at 1:58 PM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On Aug 6, 11:21 am, Sayuj Othayoth <sayujothay...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hi, >> > >> > My models: >> > >> > #StatusMessage model >> > *class StatusMessage < ActiveRecord::Base >> > belongs_to :users >> > default_scope :order => "created_at DESC" >> > end* >> > >> > #User Model >> > *class User < ActiveRecord::Base >> > has_many :statue_messages >> > end >> > >> > *In controller I want to join these two tables. >> > When I use : >> > *@status = User.joins(:status_messages)* >> > >> > It generate an error >> > >> > Association named ''status_messages'' was not found; perhaps you >> misspelled it? >> > >> > How can I fix this? >> >> It looks like you misspelled your association - your has_many doesn''t >> match what you''ve passed to User.joins >> >> Fred >> > >> > - >> > Sayuj Othayoth >> >> -- >> 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. >> >> > -- > 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. >-- 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.