First, some background. I have a Payment model that has_many :subscriptions. When a user pays (creates a new payment), I have an after_create callback that adds the newly created @payment.id to @subscriptions.payment_id. Here's what it looks like:

def update_subscription
  @unpaid_subs = Subscription.where(:user_id =&gt; self.user_id).unpaid
  @unpaid_subs.each do |sub|
    sub.payment_id = self.id
    sub.start # call to state_machine to change state from pending -&gt; active
    sub.save
  end
end


I know that doing database queries inside a loop is generally not good for performance, but I don't know any way to update multiple records at the same time. Also, is there a way to pass the @unpaid_subs instance variable from my create action to the callback (it's the same query on both) so that I can remove the query here?


Question: How can I put page through printer without cartridge?
Answer: It cannot possibly be the ink cartridges. 

It's a Laser Printer - the print heads don't go anywhere near the paper path.
Think of it like offset litho.
Ink > roller > paper

The paper path may be 180˚ away from the initial ink [toner] transfer

See Wikipedia - Laser printing

Or, if you really need to see the parallel - Offset Lithography [printing]