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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:18:50+00:00 2026-06-17T23:18:50+00:00

Thanks in advance for any help you can provide! For my Ruby on Rails

  • 0

Thanks in advance for any help you can provide!

For my Ruby on Rails website (1.8.7, 2.3.15) I’m trying to pull data from a MySQL table, but I’m running into an “Undefined Method” error. My goal with this code is to display a text list of all locations that fall within a certain latitude and longitudinal range.

Production.log:

ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #31 of     app/views/its/map.html.erb:
28: <!-- TestingLocations -->
29: 
30: <ul id="locations">
31: <% for masterlocation in @nearbylocations %>
32:     <li><%= masterlocation.nickname %></a></li>
33: <% end %>
34: </ul>

Map controller:

def map
@its = Its.find(params[:id])
if @its.user_id == current_user.id
@locations = Location.find(:all, :conditions => ["its_id = ?", params[:id]], :order => "order_num asc")
@mapscount = Saved.count(:all, :conditions => ['its_id = ?', params[:id]])
#@date_filter = Date.civil(params[:date_filter].values_at(:year, :month, :day))
#    debugger
respond_to do |format|
format.html # map.html.erb
format.xml  { render :xml => @its }
end
else
redirect_to '/'

@nearbylocations = Masterlocation.find(:all, :conditions => ["latitude > 25 AND latitude < 30 AND longitude > -75 AND longitude < -70", params[:id]], :order => ['nickname asc'])
end

Again, I appreciate your 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-06-17T23:18:51+00:00Added an answer on June 17, 2026 at 11:18 pm

    This happens because @nearbylocations is nil where as it is expecting an Array

    you can avoid this by using

    <% for masterlocation in @nearbylocations %>
      <li><%= masterlocation.nickname %></a></li>
    <% end if @nearbylocations %>
    

    I also notice that you are declared instance variable after redirecting.
    Ideally

    redirect_to '/'
    @nearbylocations = Masterlocation.find(:all, :conditions => ["latitude > 25 AND latitude < 30 AND longitude > -75 AND longitude < -70", params[:id]], :order => ['nickname asc'])
    

    should be

    @nearbylocations = Masterlocation.find(:all, :conditions => ["latitude > 25 AND latitude < 30 AND longitude > -75 AND longitude < -70", params[:id]], :order => ['nickname asc'])
    redirect_to '/'
    

    But after redirection you can’t use @nearbylocations so you have to use either render or declare it in redirected method.

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

Sidebar

Related Questions

Thanks in advance for any help you can provide! I have a website built
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance for any help you can provide! I've reviewed similar articles on
Hello and thanks in advance for any help you can provide. My AIR application
Thanks for any help in advance, I can't wrap my SQL skills around this
i have very serious problem if any tech expert can help...thank you in advance..
I am using c# .net. Thanks in advance for any help. I have searched
I have the following problem, thanks in advance for any help regarding this issue.
I hoping someone can help me with a MySQL query. I am trying to
Can any help, please> Can anyone provide me with the basics of passing (interprocess)

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.