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 7159423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:13:45+00:00 2026-05-28T13:13:45+00:00

In my Rails3 app I have AR scope which requires 3 parameters Ex: I’m

  • 0

In my Rails3 app I have AR scope which requires 3 parameters

Ex: I’m trying to get an error details for a given module between two code values

#select * from error_codes where error_module_id=1 and code >0 and code < 100

scope :latest_error_code, lambda{ |module_id, min, max|
    {:conditions => "error_module_id=#{module_id} and code >= #{min} and code <= #{max}"}
} 

in my console I do

ErrorCode.latest_error_code(1,0,100)

But when I try to execute this, I’m getting the following error

multiple values for a block parameter (3 for 1)

and when i did some goggling, it appears to be that AR scope doent support multiple parameters

1 – is it true? (AR doent support multiple params for scope)
2 – Is there any other alternative?
3 – Am I doing something wrong here?

thanks in advance

  • 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-05-28T13:13:45+00:00Added an answer on May 28, 2026 at 1:13 pm

    From the Active Record Query Interface Guide:

    Using a class method is the preferred way to accept arguments for scopes.

    So you probably want something more like this:

    def self.latest_error_code(module_id, min, max)
        where(
            'error_module_id = :module_id and code between :min and :max',
            :module_id => module_id, :min => min, :max => max
        )
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Rails app in which I have two models: a Machine model
in a Rails 3.2 app I have a search field which draws on the
I have the following named scopes in my rails app: scope :published, :conditions =>
I am trying to learn rails from zero programming experience and have an app
I have a simple rails app that is like an event system which has
I have a rails app with the following routes root :to => pages#home scope
I have a Rails 3.1.3 app which uses devise for users authentication and soft-deletes
On my rails app I have a list of items (like a task list)
In a Rails app I have Sales and Salespeople: class Sale < ActiveRecord::Base belongs_to
I am creating a rails app and have used this code in one of

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.