Ruby on Rails – Deleting a value from an array
I needed to remove users who were already assigned from a drop down list for assignments. This did the trick.
# ——————- new ——————————
—# We want to show a list of people that the user can assign a complaint to. However, we do not want to send# to people who have already been assigned to the complaint. So# 1. Pluck the user names from the User table using unique# 2. Pull the histories that match the complaint ID and put them in @existing_sent_to This should be a small list# 3. Go through the existing_sent_to and use @users.delete to remove the sent to name from the @users
def new @history = History.new
@users = User.uniq.pluck(:name) @existing_sent_to = History.where(:complaint_id =>
@existing_sent_to.each do |remove_existing|
- Going back two pages in Ruby on Rails
- A deadman’s switch for google. – Allow someone access if you no longer check into google.
- Verizon Fios emails to AOL bouncing – Can’t these two play nice??
- Retrieving data from a dead windows laptop hard drive with an external USB HD enclosure
- A nasty ransomware trojan
- Ruby on Rails – Show a field only if the controller is ‘new’
- Kodak “easyshare” won’t run right on limited accounts
- Open dialog was not opening in Office 2007 – SOLVED