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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:37:12+00:00 2026-05-31T10:37:12+00:00

I have a Listing model in my rails app. I have atable with all

  • 0

I have a Listing model in my rails app. I have atable with all the listings and a listing_controller class. What I want to do is invoke a method I wrote in the listing_controller. Here is this method:

class ListingsController < ApplicationController
  def around
      lat = params[:latitude]
      long = params[:longitude]
      @surroundings = Listing.where("latitude = :lat and longitude = :long", :lat lat, :long long)  
  end
end

Here is my around.html.erb file

<h1>Surroundings</h1>


<%=@surroundings.inspect%>


<br/>
<%= debug(params) if Rails.env.development? %>
<br/>

Now my listings table has 2 columns: latitude and longitude both string types.

I would like to test the “around” method that I wrote

Here is my routes.rb file

Businesses::Application.routes.draw do

  resources :listings
  root to: 'listings#index', as: 'listings'

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

Now my understanding is this in order to invoke a method of a controller I need to construct a url and append the method to be invoked after listings like so….

http://localhost:3000/listings/around

but Im failing to understand how will I give the 2 parameters (latitude and longitude) to this method?? Where and how in the url can I add them..

please help

  • 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-31T10:37:14+00:00Added an answer on May 31, 2026 at 10:37 am

    I guess you are talking about regular http get parameters. You can just add them to your URL beginning in the style of ?param1=value1&param2=value2&....

    In your example, you would write something like http://localhost:3000/listings/around?latitude=3.455&longitude=15.2228.

    To generate such a URL using the Rails helper, the syntax should be something like listings_around_path(:latitude => "3.455", :longitude => "15.2228").

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

Sidebar

Related Questions

I have a listings_controller in my rails app along with a Listing model. The
I have a model User and Listing in my rails app. User has many
Have an app that has listings - think classified ads - and each listing
Hi I have a model called Listing. Here is the constructor for the model:
I have a django admin interface and in the model listing I want a
I have the following code to generate a table listing brand/model/submodel/style for a group
In my Django app I have a listing of items with a 'delete' option
I have a directory listing for which I want to retrieve the filenames and
I have a product listing page and want to load up a detail view
I have a query that shows me a listing of ALL opportunities in one

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.