Hi all

Oh my god, this really shouldn't be a tough one, but I just don't get
it. ;-)

class Page < ActiveRecord::Base
  def caption
    caption ? caption : title
  end
end

I want to return the content of the title column when the caption column
is empty:

p.caption # Caption is not empty
# => "caption"

p.caption # Caption is empty
# => "title"

Not astonishing, I get a StackLevelTooDeep Exception with my "solution"
above... But how can I do it right?

Thanks a lot... My brain is just a bit wrecked today...
Josh
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to