Thoughts, information and reflections about technology

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
users User.uniq.pluck(:name) @existing_sent_to History.where(:complaint_id => 

  @existing_sent_to.each do |remove_existing|

end end

Similar Posts:

No tags for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact me
Recent Comments