Skip to content

Instantly share code, notes, and snippets.

@quirkey
Created February 11, 2009 00:18
Show Gist options
  • Select an option

  • Save quirkey/61713 to your computer and use it in GitHub Desktop.

Select an option

Save quirkey/61713 to your computer and use it in GitHub Desktop.
if Book.exists?(:title => title) # SELECT #=> true/false
book = Book.find_by_title(title) # SELECT #=> Book
...
if book = Book.find_by_title(title) # SELECT || nil
...
if book = Book.find_by_title(title) && company = Company.find_by_name(name)
...
if book = (Book.find_by_title(title) && company = Company.find_by_name(name))
# book => (boolean)
# company => (<Company>)
if (book = Book.find_by_title(title)) && (company = Company.find_by_name(name))
# book => (boolean)
# company => (<Company>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment