title: Rails 4 - setting belongs_to relationship not working
body: <p>I have two models, <code>Team</code> and <code>Plan</code>. Team has a one to many relationship with plans, where plans can have many teams and each team have one plan. It looks like this:</p>
  
  <pre><code>#Plan
  has_many :teams
  
  #Team
  belongs_to :plan
  </code></pre>
  
  <p>I'm using <a href="https://www.stripe.com" rel="nofollow">Stripe</a> for recurring billing, and I'm using <code>[webhooks][2]</code> to keep my app synced with Stripe. To receive Stripe events I'm using the gem <code>[stripe_event][3]</code>. When subscriptions are created I want to set the plan to the newly created subscription plan. When I get the Stripe event <code>customer.subscription.created</code> I do the following:</p>
  
  <pre><code>events.subscribe 'customer.subscription.created' do |event|
    team = Team.find_by_stripe_customer_id(event.data.object.customer)
    create_subscription_for_team(team, event.data.object)
  
    # In this methods I want to set my plan
    set_team_plan(team, event.data.object.plan)
  end
  
  def set_team_plan(team, plan)
    team_plan = Plan.find_by_stripe_id(plan.id)
    team.update_attribute(plan_id: team_plan.id)
  end
  </code></pre>
  
  <p>I don't get any errors what I can see, but the plan don't seem to get updated. I have also tried:</p>
  
  <pre><code>team.plan = team_plan
  team.save!
  </code></pre>
  
  <p>But this gives me the same result. When I have logged I have confirmed that <code>team_plan</code> is the correct plan, and is not nil. </p>
  
  <p>Any ideas on what I'm doing wrong?</p>