Hi, I''ve 2 tables 1. Users 2. StatusMessages @user = Users.find(1) @status = @user.status_messages with these lines I''m getting the record of users and status_messages table. here I can refer in @status with @user.id for status messages of each user. in this I want to check this for each user in my code. is there any way to get the data - username(from Users) and status_message(from StatusMessage) in a single variable. ie I want to access like: *@userstatus.username @userstatus.status_message* I''m using rails 3.1 Thank you, Sayuj -- 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 8 August 2011 09:55, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > I''ve 2 tables > 1. Users > 2. StatusMessages > > @user = Users.find(1) > @status = @user.status_messages > > with these lines I''m getting the record of users and status_messages table. > here I can refer in @status with @user.id for status messages of each user. > in this I want to check this for each user in my code. > > is there any way to get the data - username(from Users) and > status_message(from StatusMessage) in a single variable. > ie I want to access like: > @userstatus.username > @userstatus.status_messageIf @status_message is a StatusMessage then you can say @status_message.user.name @status_message.message or whatever the column names are. This assumes that StatusMessage belongs_to :user Does that solve the problem? If you don''t want to use @status_message.user.name but would rather say @status_message.user_name then define an instance method of StatusMessage that returns user.name. In either case don''t forget to check for @status_message.user nil if you can ever have a message without a user. Colin -- 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.
Hi Colin, It results: NoMethodError in Status_message#index Showing * /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb*where line *#9* raised: undefined method `unscoped'' for Users:Module What I need to do to fix this? On Mon, Aug 8, 2011 at 2:46 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 09:55, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > > > I''ve 2 tables > > 1. Users > > 2. StatusMessages > > > > @user = Users.find(1) > > @status = @user.status_messages > > > > with these lines I''m getting the record of users and status_messages > table. > > here I can refer in @status with @user.id for status messages of each > user. > > in this I want to check this for each user in my code. > > > > is there any way to get the data - username(from Users) and > > status_message(from StatusMessage) in a single variable. > > ie I want to access like: > > @userstatus.username > > @userstatus.status_message > > If @status_message is a StatusMessage then you can say > @status_message.user.name > @status_message.message > or whatever the column names are. This assumes that StatusMessage > belongs_to :user > > Does that solve the problem? > > If you don''t want to use @status_message.user.name but would rather > say @status_message.user_name then define an instance method of > StatusMessage that returns user.name. In either case don''t forget to > check for @status_message.user nil if you can ever have a message > without a user. > > Colin > > -- > 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.
On 8 August 2011 10:36, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Please don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in the previous message. Thanks. If you could manage to post in plain text rather than html it would also make life more pleasant for some of us.> Hi Colin, > > It results: > > NoMethodError in Status_message#index > > Showing > /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb > where line #9 raised: > > undefined method `unscoped'' for Users:ModulePerhaps if you showed us the line causing the problem (and a few lines around it) it might be easier to suggest a solution. Also show the model class definitions for user and statusmessage. Copy and paste the code, do not retype it. Also tell us anything unusual about your setup. Are you using an authorisation gem for example? Colin -- 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 Mon, Aug 8, 2011 at 3:19 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 10:36, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Please don''t top post, it makes it difficult to follow the thread. > Insert your reply at appropriate points in the previous message. > Thanks. > If you could manage to post in plain text rather than html it would > also make life more pleasant for some of us. > > > Hi Colin, > > > > It results: > > > > NoMethodError in Status_message#index > > > > Showing > > /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb > > where line #9 raised: > > > > undefined method `unscoped'' for Users:Module > > Perhaps if you showed us the line causing the problem (and a few lines > around it) it might be easier to suggest a solution. > Also show the model class definitions for user and statusmessage. > Copy and paste the code, do not retype it. > > Also tell us anything unusual about your setup. Are you using an > authorisation gem for example? > > Colin > > -- > 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. > >Please see my code. I am using devise as authentication controller. MODELS: class User < ActiveRecord::Base #has_and_belongs_to_many :roles has_many :status_messages # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me # def role?(role) # return !!self.roles.find_by_name(role.to_s.camelize) # end end class StatusMessage < ActiveRecord::Base belongs_to :users #default_scope :order => "created_at DESC" end CONTROLLER: class StatusMessageController < ApplicationController def index @status = StatusMessage.all end def create @status = StatusMessage.new @status.user_id = current_user.id @status.status = params[:status] @status.save redirect_to :action => "index" end end ERB: <h1>Home</h1> <%= form_tag do |f| %> <%= text_area_tag :status %> <%= submit_tag "Submit" %> <% end %> <br /> *<% @status.each do |s| %> <%= s.users.email %> <%= s.status %> <br /> <% end %>* ERROR MSG: NoMethodError in Status_message#index Showing * /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb*where line *#9* raised: undefined method `unscoped'' for Users:Module Extracted source (around line *#9*): 6: <% end %> 7: <br /> 8: <% @status.each do |s| %> 9: <%= s.users.email %> 10: <%= s.status %> <br /> 11: <% 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-/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 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> [...] > Please see my code. I am using devise as authentication controller. > > MODELS: > > class User < ActiveRecord::Base > #has_and_belongs_to_many :roles > has_many :status_messages > # Include default devise modules. Others available are: > # :token_authenticatable, :encryptable, :confirmable, :lockable, > :timeoutable and :omniauthable > devise :database_authenticatable, :registerable, > :recoverable, :rememberable, :trackable, :validatable > > # Setup accessible (or protected) attributes for your model > attr_accessible :email, :password, :password_confirmation, :remember_me > > # def role?(role) > # return !!self.roles.find_by_name(role.to_s.camelize) > # end > end > > class StatusMessage < ActiveRecord::Base > belongs_to :usersThat should be :user, singular.> #default_scope :order => "created_at DESC" > end > > CONTROLLER: > > class StatusMessageController < ApplicationController > def index > @status = StatusMessage.all > end > > def create > @status = StatusMessage.new > @status.user_id = current_user.id > @status.status = params[:status] > @status.save > redirect_to :action => "index" > end > > end > > > ERB: > > <h1>Home</h1> > <%= form_tag do |f| %> > <%= text_area_tag :status %> > <%= submit_tag "Submit" %> > <% end %> > <br /> > <% @status.each do |s| %> > <%= s.users.email %>That should be s.user.email. Each message has just one user. Colin -- 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 Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > [...] > > Please see my code. I am using devise as authentication controller. > > > > MODELS: > > > > class User < ActiveRecord::Base > > #has_and_belongs_to_many :roles > > has_many :status_messages > > # Include default devise modules. Others available are: > > # :token_authenticatable, :encryptable, :confirmable, :lockable, > > :timeoutable and :omniauthable > > devise :database_authenticatable, :registerable, > > :recoverable, :rememberable, :trackable, :validatable > > > > # Setup accessible (or protected) attributes for your model > > attr_accessible :email, :password, :password_confirmation, :remember_me > > > > # def role?(role) > > # return !!self.roles.find_by_name(role.to_s.camelize) > > # end > > end > > > > class StatusMessage < ActiveRecord::Base > > belongs_to :users > > That should be :user, singular. > > > #default_scope :order => "created_at DESC" > > end > > > > CONTROLLER: > > > > class StatusMessageController < ApplicationController > > def index > > @status = StatusMessage.all > > end > > > > def create > > @status = StatusMessage.new > > @status.user_id = current_user.id > > @status.status = params[:status] > > @status.save > > redirect_to :action => "index" > > end > > > > end > > > > > > ERB: > > > > <h1>Home</h1> > > <%= form_tag do |f| %> > > <%= text_area_tag :status %> > > <%= submit_tag "Submit" %> > > <% end %> > > <br /> > > <% @status.each do |s| %> > > <%= s.users.email %> > > That should be s.user.email. Each message has just one user. > > Colin > > -- > 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. > > Colin,When I use s.user.email, it shows: NoMethodError in Status_message#index Showing * /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb*where line *#9* raised: undefined method `user'' for #<StatusMessage:0xb126384> Extracted source (around line *#9*): 6: <% end %> 7: <br /> 8: <% @status.each do |s| %> 9: <%= s.user.email %> 10: <%= s.status %> <br /> 11: <% 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-/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 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > [...] >> > class StatusMessage < ActiveRecord::Base >> > belongs_to :users >> >> That should be :user, singular.Did you make this correction as I suggested previously, so it should be belongs_to :user (each message belongs to one user so singular) Colin> When I use s.user.email, it shows: > > NoMethodError in Status_message#index > > Showing > /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb > where line #9 raised: > > undefined method `user'' for #<StatusMessage:0xb126384> > > Extracted source (around line #9): > > 6: <% end %> > 7: <br /> > 8: <% @status.each do |s| %> > 9: <%= s.user.email %> > 10: <%= s.status %> <br /> > 11: <% 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-/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 Mon, Aug 8, 2011 at 4:42 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> > >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > [...] > >> > class StatusMessage < ActiveRecord::Base > >> > belongs_to :users > >> > >> That should be :user, singular. > > Did you make this correction as I suggested previously, so it should > be belongs_to :user (each message belongs to one user so singular) > > Colin >Yes I made the changes. Error is "undefined method *`user''* for #<StatusMessage:0xb126384>"> > > When I use s.user.email, it shows: > > > > NoMethodError in Status_message#index > > > > Showing > > /home/sayuj/work/sayuj/microblog/app/views/status_message/index.html.erb > > where line #9 raised: > > > > undefined method `user'' for #<StatusMessage:0xb126384> > > > > Extracted source (around line #9): > > > > 6: <% end %> > > 7: <br /> > > 8: <% @status.each do |s| %> > > 9: <%= s.user.email %> > > 10: <%= s.status %> <br /> > > 11: <% 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-/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.
On 8 August 2011 12:34, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Mon, Aug 8, 2011 at 4:42 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > >> > >> > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> > wrote: >> >> >> >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > [...] >> >> > class StatusMessage < ActiveRecord::Base >> >> > belongs_to :users >> >> >> >> That should be :user, singular. >> >> Did you make this correction as I suggested previously, so it should >> be belongs_to :user (each message belongs to one user so singular) >> >> Colin > > > Yes I made the changes. > Error is "undefined method `user'' for #<StatusMessage:0xb126384>"Could you post the code for the StatusMessage class again please? Colin -- 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 Mon, Aug 8, 2011 at 5:54 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 August 2011 12:34, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Mon, Aug 8, 2011 at 4:42 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> > >> On 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > > >> > > >> > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > >> > wrote: > >> >> > >> >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> >> > [...] > >> >> > class StatusMessage < ActiveRecord::Base > >> >> > belongs_to :users > >> >> > >> >> That should be :user, singular. > >> > >> Did you make this correction as I suggested previously, so it should > >> be belongs_to :user (each message belongs to one user so singular) > >> > >> Colin > > > > > > Yes I made the changes. > > Error is "undefined method `user'' for #<StatusMessage:0xb126384>" > > >Could you post the code for the StatusMessage class again please? > > class StatusMessage < ActiveRecord::Basebelongs_to :users default_scope :order => "created_at DESC" end Colin> > -- > 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.
On Tue, Aug 9, 2011 at 11:08 AM, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On Mon, Aug 8, 2011 at 5:54 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 8 August 2011 12:34, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > >> > >> > On Mon, Aug 8, 2011 at 4:42 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> wrote: >> >> >> >> On 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> > >> >> > >> >> > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> >> > wrote: >> >> >> >> >> >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> >> > [...] >> >> >> > class StatusMessage < ActiveRecord::Base >> >> >> > belongs_to :users >> >> >> >> >> >> That should be :user, singular. >> >> >> >> Did you make this correction as I suggested previously, so it should >> >> be belongs_to :user (each message belongs to one user so singular) >> >> >> >> Colin >> > >> > >> > Yes I made the changes. >> > Error is "undefined method `user'' for #<StatusMessage:0xb126384>" >> >> >Could you post the code for the StatusMessage class again please? >> >> class StatusMessage < ActiveRecord::Base > belongs_to :users > default_scope :order => "created_at DESC" > end > >I should use *belongs_to :user *instead of *belongs_to :users* Thank you Colin.> > Colin >> >> -- >> 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.
On 9 August 2011 07:00, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Tue, Aug 9, 2011 at 11:08 AM, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> >> On Mon, Aug 8, 2011 at 5:54 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>> On 8 August 2011 12:34, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > >>> > >>> > On Mon, Aug 8, 2011 at 4:42 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >>> > wrote: >>> >> >>> >> On 8 August 2011 11:40, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> >> wrote: >>> >> > >>> >> > >>> >> > On Mon, Aug 8, 2011 at 4:06 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >>> >> > wrote: >>> >> >> >>> >> >> On 8 August 2011 11:17, Sayuj Othayoth <sayujothayoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> >> >> wrote: >>> >> >> > [...] >>> >> >> > class StatusMessage < ActiveRecord::Base >>> >> >> > belongs_to :users >>> >> >> >>> >> >> That should be :user, singular. >>> >> >>> >> Did you make this correction as I suggested previously, so it should >>> >> be belongs_to :user (each message belongs to one user so singular) >>> >> >>> >> Colin >>> > >>> > >>> > Yes I made the changes. >>> > Error is "undefined method `user'' for #<StatusMessage:0xb126384>" >>> >>> >Could you post the code for the StatusMessage class again please? >>> >> class StatusMessage < ActiveRecord::Base >> belongs_to :users >> default_scope :order => "created_at DESC" >> end >> > > I should use belongs_to :user instead of belongs_to :usersIn my initial post I pointed out two errors. That was one of them. Then later I queried whether you had made that correction and you said you had. Colin -- 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.