Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your example is not functionally equivalent as address is a model instance with many address-related properties. Though I agree with your general premise. This, to me, seems like the Tell, Don't Ask solution:

    class User
      delegate :street_name, to: :address, prefix: true, allow_nil: true
    end

    <%= user.address_street_name || "No street name on file" %>


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: