title: private method in controller to get object
body: <pre><code>module Api  
     class ApiController &lt; ApplicationController
  
      before_filter :authenticate        
      private
        def authenticate
          #check if GET parameter
          return true if @user = User.find_by_token(params[:token])
  
          #check if token in header
          authenticate_or_request_with_http_token do |token, options|
             @user = User.find_by_token(token)
          end      
        end      
    end
  end
  
  module Api
    module V1
      class AdvertisementImagesController &lt; ApiController
  
        def index
          @images = images
        end
  
        def create
          if images.create :remote_image_url=&gt;params[:image][:remote_image_url] 
            return render :nothing =&gt; true, :status=&gt;201
          else
            return render :nothing =&gt; true, :status=&gt;500
          end
  
       private
        def images
          @user.advertisements.find(params[:advertisement_id]).images  
        end
  </code></pre>
  
  <p>throws </p>
  
  <pre><code>undefined local variable or method `images' for #&lt;Api::V1::AdvertisementImagesController:0xb2d558d8&gt;
  </code></pre>
  
  <p>If i put the Method in the ApiController, then it is working. </p>
  
  <pre><code>#in ApiControler
  private        
    def images
      @user.advertisements.find(params[:advertisement_id]).images  
    end
  </code></pre>
  
  <p>if i put the method in the images_controller, then its giving an error.</p>
  
  <p>What is the Problem?</p>