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
- Ruby on Rails – Show a field only if the controller is ‘new’
- Retrieving data from a dead windows laptop hard drive with an external USB HD enclosure
- A nasty ransomware trojan
- Kodak “easyshare” won’t run right on limited accounts
- Removing obsolete database tables from your Joomla site.
- DB Replacer – Mass changes for your Joomla Site
- Running Rails Console in production while using Spring