I have done many variations of this code.  Essentially I want this to be
true.


assert_equal '', Org.field_for(nil).display


This is a polymorphic relationship.

fieldable.rb
============

def field_for(purpose)
  self.fields.find(
   :first,
   :conditions => ["purpose LIKE ?", "#{purpose}"],
   :order => 'position asc')
end # def



field.rb
========
def display
 str = ""
 field.to_s unless search.blank?
 str
end


Can someone help tell me what I'm doing wrong and why I can't produce an
empty string?  I had thought that nil.to_s created an empty string, but
just writing the following didn't work either.

def display
  field.to_s
end


Thanks!
-- 
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