title: How do I enter a record for every user where condition is true in Rails
body: <p>So I have app that has political candidates.</p>
  <p>When a new political candidate is entered, I want to enter a notification into the notifications table for every user that's state is equal to the state of the new candidate being entered.</p>
  <p>Ultimately, I want to enter in records to the notification table for every single user where that condition is met.</p>
  <p>I know I'm way off, but here's where I'm at now. I'm trying to loop through each user and then enter this record when that condition is true.</p>
  <pre><code>  def create
      @candidate = Candidate.new(candidate_params)
      if @candidate.save
        User.each do |u|
          if Candidate.state == User.state
            @notification = Notification.new(:message =&gt; 'Message', :user_id =&gt; U.id)
            @notification.save
          else 
          end
        end
      else
        render('new')
      end
    end
  </code></pre>
  <p>The candidate is created with this code, but the notifications aren't working. Basically I have two users where their state equals &quot;Arizona&quot; and I would expect if I create a new candidate where the state is &quot;Arizona&quot; that I should get two record into notifications, one with each user ID.</p>