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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:26:05+00:00 2026-06-02T01:26:05+00:00

Hi I have a class ‘listings_controller’. I added a method ‘list’ in there as

  • 0

Hi I have a class ‘listings_controller’. I added a method ‘list’ in there as follows:

def index     
    @listings = Listing.order(:name)  
end  


def list  
    render :text=>(@listings).to_json  
end  

Here is my routes.rb file

root to: ‘listings#index’, as: ‘listings’
resources :listings do
collection do
get :around
end
end

match ':controller(/:action(/:id))(.:format)'  

When I type this into my browser:

http://localhost:3000/listings/list

I hope to see the JSON object and its contents in the browser. However, thats not happening. I was wondering if someone could assist me in diagnosing what Im doing wrong.

The webrick server says the following:

Started GET "/listings/list" for 127.0.0.1 at 2012-04-18 11:56:25 -0700  
Processing by ListingsController#show as HTML  
Parameters: {"id"=>"list"}  
Listing Load (0.3ms)  SELECT "listings".* FROM "listings" WHERE "listings"."id" = ? LIMIT 1  [["id", "list"]]  
Completed 500 Internal Server Error in 2ms  

ActiveRecord::RecordNotFound (Couldn’t find Listing with id=list):
app/controllers/listings_controller.rb:104:in `show’

  • 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-02T01:26:08+00:00Added an answer on June 2, 2026 at 1:26 am

    Add the following in your routes.rb:

    match 'listings/list' => 'listings#list'

    Or the shorthand:

    get 'listings/list'

    At the moment it is being routed to the show method.

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

Sidebar

Related Questions

I have class X and in it there is a static method called doStuff()
I have class method that returns a list of employees that I can iterate
I have class A and list of A objects. A has a function f
I have class in server side and I want use method of this class
I have :- Class Abc extends Activity(){ private ActivityManager am; private List<RunningAppProcessInfo> rList; @Override
I have class methods like these in a message model: def delete_all_users_messages(user_id, parent_id) message
I have Class called Person containing to properties, Father and List of Children. I
I have class: @custom_decorator class Creature(objects): def __init__(self): pass def rise_hands(self, *args, **kwargs): print
I have class which has a method that needs to return three DataTables. I
I have class Authors has_many :books, :order => 'name ASC' I am trying to

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.