title: can Belongs_to work without has_many or has_one
body: <p>I am studying Belongs_to association, I have used following models, in that every order belongs to the customer, so I have used belongs_to in order model it giving error while creating order</p>
  
  <blockquote>
    <p>undefined method `orders' for #</p>
  </blockquote>
  
  <ol>
  <li><p>when I use has_many :orders in customer model it works fine, why it
  does not work with only belongs_to</p></li>
  <li><p>Its work with has_many :orders in customer model but not with
  has_one : order in customer controller it giving same above error.</p></li>
  </ol>
  
  <p>thanks in advance.</p>
  
  <p>Model :- order.rb</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
    belongs_to :customer
    attr_accessible :order_date, :customer_id
  end
  </code></pre>
  
  <p>Model :- customer.rb</p>
  
  <pre><code>class Customer &lt; ActiveRecord::Base
    attr_accessible :name
  end
  </code></pre>
  
  <p>controller :- orders.rb</p>
  
  <pre><code>  def create
       @customer = Customer.find_by_name(params[:name])
      @order = @customer.orders.new(:order_date =&gt; params[:orderdate] )
  
      respond_to do |format|
        if @order.save
          format.html { redirect_to @order, notice: 'Order was successfully created.' }
          format.json { render json: @order, status: :created, location: @order }
        else
          format.html { render action: "new" }
          format.json { render json: @order.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>