Skip to content

Instantly share code, notes, and snippets.

@carlallen
Created June 14, 2011 22:33
Show Gist options
  • Save carlallen/1026104 to your computer and use it in GitHub Desktop.
Save carlallen/1026104 to your computer and use it in GitHub Desktop.
Rails Questions
>> User.first.email
>> User.all.collect{|u| u.status}.uniq.size
>> User.update_all("status = 'Hired'", "id = #{params[:id]}")
>> @user = User.find(*params[:ids]) and @user.name or "User not found"
>> User.where(:status => 'Hired').first == User.find{|u| u.status = "Hired"}
>> User.active.collect(&:address).compact.map(&:country).inject{|m, c| c.code}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment