Hello all, Im getting a nil object error. here under are the details of my app. My index.rhtml file is <% @result.each do |res| %> <%= res.first_name %> <br> <%= res.register.language_speak %> <br><br><br><br> <% end %> My models are as follows class Profile < ActiveRecord::Base has_many :friends, :foreign_key => "user_id" has_one :register, :foreign_key => "id" def self.table_name() "mhp_profile" end end class Friend < ActiveRecord::Base belongs_to :profile def self.table_name() "mhp_friends" end end class Register < ActiveRecord::Base belongs_to :profile def self.table_name() "mhp_register" end end But Im getting the following error. Showing *profile/index.rhtml* where line *#4* raised: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.language_speak Any idea what am I doing wrong...I have only one controller for profile as follows class ProfileController < ApplicationController def index @result = Profile.find(:all) end end -- Regards Haris Gulzar --~--~---------~--~----~------------~-------~--~----~ 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 profile may not have the register in mhp_register table. Check whether there is any record for the profile in mhp_register table. Or else, the table attribute name might be incorrect. - Karthik. -- Posted via http://www.ruby-forum.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-/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 Jan 2, 2008, at 3:42 AM, Haris Gulzar wrote:> Hello all, > > Im getting a nil object error. here under are the details of my > app. My index.rhtml file is > > <% @result.each do |res| %> > <%= res.first_name %> > <br> > <%= res.register.language_speak %>I provided a possible solution in the other thread you asked this in. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---