Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:48:39+00:00 2026-06-14T08:48:39+00:00

I receive undefined method ‘search_type’ for the code below. Can you tell me what

  • 0

I receive undefined method 'search_type' for the code below. Can you tell me what am I doing wrong here? Probably something with calling private functions, but I can’t find what the problem is.

class Entry < ActiveRecord::Base
  attr_accessible :content, :rank, :title, :url, :user_id

  def self.search(params)
    t, o = search_type(params[:type]),search_order(params[:order])
    scope = self

    scope = scope.where(t) if t
    scope.order(o).page(params[:page]).per_page(20)
  end

  private

  def search_order(order)
    return 'comments_count DESC' if order == '1'
    return 'points DESC' if order == '2'

    'rank DESC'
  end

  def search_type(type)
    return nil unless type.present?

    "entry_type = #{type}"
  end
end

In the controller, I have only @entries = Entry.search(params).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:48:40+00:00Added an answer on June 14, 2026 at 8:48 am

    It’s not to do with the privateness of your methods, but the fact that search is a class method, so when you call search_order from within it, it is looking for a class method called search_order but you’ve defined search_order as in instance method.

    Make your 2 helper methods class methods and you should be ok. if you want them to be private class methods, then

    class << self
      def search(...)
      end
      private
      def search_type(...)
      end
      def search_order(...)
      end
    end
    

    If you are wondering why @entries.search(...) works it’s because I assume that @entries is something like Entry.where(...) ie, a scope and you can call class methods on scopes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I receive a date in the format below from a json file. Im not
I receive TypeError: Can't convert 'float' object to str implicitly while using Gambler.pot +=
I'm running into something weird here. I have an authenticator that relies on ND5
It seems that the inheritsFrom: method in GNU Smalltalk returns true for every undefined
I have GetURL method defined to find my location from network provider, you can
I have the following code loop(Data) -> receive {Key, Value} -> [{Key, Value}|Data]; {Key}
I need render a partial content inside observer. I get this error: undefined method
I receive this error when I click on the section of my Tab-Bar application
I receive the following error in Microsoft SQL Server Report Builder Error While generating
We receive (#4) Application request limit reached error when a page is showing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.