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

  • SEARCH
  • Home
  • 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 6659455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:02:11+00:00 2026-05-26T02:02:11+00:00

I’m new to rails and I’m currently using 2.3.8. I’m designing a web service

  • 0

I’m new to rails and I’m currently using 2.3.8. I’m designing a web service for an iOS app.

As I’m normally a client side iPhone developer, my knowledge of server side implementation is shamefully minimal.

The problem I’m having is that I’m trying to pass some params in a GET request to the index action in one of my controllers. This is routed using the default

map.resources :dishes

where dishes is the name of the controller, created with scaffold.

I would like to pass multiple params to either a new action or to the index, which will allow me to filter the dish objects to return.

The index method looks like

def index
    if(params[:latitude])
     @min = 0.5 - 1
      @max = 0.5 + 1
      @locations = Location.find(:all, :conditions => [":latitude > ? AND :latitude < ?", @min, @max])
        @dishes = new Array
        @locations.each do |loc| 

          @dishes = @dishes + loc.dishes

        end

        respond_to do |format|
          format.html # index.html.erb
          format.json {render :json => @dishes.to_json(:except => [ :user_id, :location_id , :like_id], :include => { :user => { :only => [:id, :name] } }  ) }

        end
    else
      @dishes = Dish.all

      respond_to do |format|
        format.html # index.html.erb
        format.json {render :json => @dishes.to_json(:except => [ :user_id, :location_id , :like_id], :include => { :user => { :only => [:id, :name] } }  ) }

      end
    end
end

I am currently getting the following error when I pass in an extra param

ArgumentError in DishesController#index
wrong number of arguments (1 for 0)

The full error:

ArgumentError in DishesController#index
wrong number of arguments (1 for 0)
RAILS_ROOT: /Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5

Application Trace | Framework Trace | Full Trace
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in `new'
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in `index'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-    2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:438:in `call'
Request

Parameters:

{"format"=>"json",
 "latitude"=>"0.5"}
Show session dump

Response

Headers:

{"Content-Type"=>"",
 "Cache-Control"=>"no-cache"}

I realise this goes slightly against the RESTful design of Rails but I couldn’t work out another way to do it.

Again, I’m a new to rails / web service dev so if you have any tips I would welcome them.

Thanks.

  • 1 1 Answer
  • 1 View
  • 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-26T02:02:11+00:00Added an answer on May 26, 2026 at 2:02 am

    You have

    @dishes = new Array
    

    which is not Ruby unfortunately 🙂 There are three ways to create an instance of Array

    @dishes = Array.new
    @dishes = []
    @dishes = Array( nil )
    

    also pay attention to

    /Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in 'new'
    /Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in 'index'
    

    which tells you that error happened in new not in index

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.