I was browsing the ActiveRecord documentation and I came across notation that looks like this:
User.name?
When I looked more closely, I realized that it replaced all of the places where I had something like this:
!User.name.blank?
In other words, if the user’s name is an empty string (“”) or nil, I can call User.name? and it’ll return false. Here’s the documentation I was browsing. http://api.rubyonrails.org/classes/ActiveRecord/Base.html





Pingback: » Quick Tip: Knowing if an Object's Attribute is Empty or Nil Wordpress Hosting: Just another WordPress weblog