title: Issue when restricting number of order_items to order
body: <p>I'm building a store in Rails that has a specific sales model. I need to allow a user to add only 3 items to his order per 30 days. The 30 days counter should start upon adding the first order_item. Once 30 days expires, user would be able to add 3 orders. If 30 days didn't pass and for an example, user adds two order_items he would still be allowed to add one more order_item within 30 days. So as well if user tries to add more then 3 items to show an error message and disregard saving of the order_items to current_user's order.</p>
  
  <p>So what I did:
  I added a begin_date and a order_counter to user model. Every time I add an order, to look if the begin_date is more than 30 days ago, then set the begin_date to the actual date. If the begin_date is less than 30 days ago, to increase the counter. And if the counter is already 3 refuse the order.</p>
  
  <p>The issue:
  I can see that Order_Counter is staying at number 3 in my rails admin. However, I'm still able to add unlimited order_items to user's order.
  What did do wrong?</p>
  
  <pre><code>class OrderItemsController &lt; ApplicationController
   def create
      now = Date.today
    if current_user.begin_date &amp;&amp; ((now - 30) &lt; current_user.begin_date)
       if current_user.order_counter &gt;= 3
          redirect_to root_path
       else
         current_user.order_counter += 1
         current_user.save
       end
    else 
      current_user.order_counter = 1
      current_user.begin_date = now
      current_user.save
    end
  
  
    respond_to do |format|
      format.js { flash[:notice] = "ORDER HAS BEEN CREATED." } 
    end
  
  @order = current_order
    @order_item = @order.order_items.new(order_item_params)
    @order.user_id = current_user.id
    @order.save
    session[:order_id] = @order.id
  
  
  end
  </code></pre>
  
  <p>order_item.rb</p>
  
  <pre><code>class OrderItem &lt; ActiveRecord::Base
    belongs_to :product
    belongs_to :order
  
    validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 }
    validate :product_present
    validate :order_present
  
  
    before_save :finalize
  
    def unit_price
      if persisted?
        self[:unit_price]
      else
        product.price
      end
    end
  
    def total_price
      unit_price * quantity
    end
  
  private
    def product_present
      if product.nil?
        errors.add(:product, "is not valid or is not active.")
      end
    end
  
    def order_present
      if order.nil?
        errors.add(:order, "is not a valid order.")
      end
    end
  
    def finalize
      self[:unit_price] = unit_price
      self[:total_price] = quantity * self[:unit_price]
    end
  
  
  end
  </code></pre>
  
  <p>order.rb</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
    belongs_to :order_status
    has_many :order_items
    before_create :set_order_status
    before_save :update_subtotal
  
    def subtotal
      order_items.collect { |oi| oi.valid? ? (oi.quantity * oi.unit_price) : 0 }.sum
    end
  private
    def set_order_status
      self.order_status_id = 1
    end
  
    def update_subtotal
      self[:subtotal] = subtotal
    end
  end
  </code></pre>