That is because your name method is called recursively - the `return name + ""` is calling `name` once again and again and again... If you want to access raw attributes from database on ActiveRecord models, you can always use `self[:name]`.

It might be convenient for you to use ruby interpolations in a method like `describe`. The following is equivalent to your method (you don't need return either - the last thing evaluated is always returned from a method):

def describe
  "#{name}#{email}#{mobile}#{category}#{other}"
end

I don't understand the idea behind `+ ""`. If you want convert any value to string, it is convention in ruby to call #to_s method on it. If you use anything in an interpolation, ruby will call #to_s on this object for you.

MichaƂ.


On 24.09.2014 13:12, Mohammed Rashid wrote:
This is my controller:

class Members < ActiveRecord::Base
   def name
     return name + ""
   end

def describe
   return  name + "" + email + "" + mobile + "" + category + "" + other
end
end


when i go into the rails console and connect to Members, I say:

a = Members.first

a.name  <<< this should give me the "name" of that person but it does
not, it says:

SystemStackError: stack level too deep


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5422AB92.7040501%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to