title: Ruby on rails model method is not getting executed in controller
body: <p><strong>posts_controller.rb destroy method</strong></p>
  
  <pre><code>def destroy
  
      if !request.xhr?
          render_404
          return
      end
  
      if user_signed_in?
  
          if Post.exists?(:post_id =&gt; params[:id])
  
                  if Post.post_is_mine(params[:id], current_user.id)
  
                      @return = { :error =&gt; false, :response =&gt; "Post deleted" }
  
                  else
                      @return = { :error =&gt; true, :response =&gt; 'You are not allowed to perform this action.' }
                  end
  
              else
                  @return = { :error =&gt; true, :response =&gt; 'This post doesn\'t exist.' }
              end
  
          else
              @return = { :error =&gt; true, :response =&gt; 'Please login before you delete a post.' }
          end
  
      render :json =&gt; ActiveSupport::JSON.encode( @return )
  
  end
  </code></pre>
  
  <p><strong>post.rb</strong></p>
  
  <pre><code>  def self.post_is_mine(post_id, user_id)
      #where(:user_id =&gt; user_id, :post_id =&gt; bucket_id)
      where("user_id = ? and post_id = ?", user_id, bucket_id)
    end
  </code></pre>
  
  <p>when i check what queries are being run when i destroy a post, i can only see the <code>.exists?</code> to run but not the <code>.post_is_mine</code> which simply goes through <strong>as it returns TRUE</strong></p>
  
  <p>i tried several other names as the method since something could cause the problem or even simply trying out the if statement with <strong>.post_is_mine</strong> but still, the query was not run</p>
  
  <p>Could there be a problem on the model as to how i use the where clause?</p>