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.
Muskalek wrote in post #1158351:
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.
Thank you Michal, your post is at must help, however I have discovered a
new gem called fullcalendar. Do you think that with this, you can link
these id's so that we can view each attribute in a calendar. So
basically like the day will be on the left but then I will be able to
display this persons "#{name}#{email}#{mobile}#{category}#{other}"
also on the calendar.?