0

Ok so this is simple 101 but I am obviously doing something wrong. Can you advise how I create a params array like the below.

params = []
params[:geo_bounding_box][:top_left_lat] = @search.ne_lat
params[:geo_bounding_box][:top_left_lon] = @search.sw_lon
params[:geo_bounding_box][:bottom_right_lat] = @search.sw_lat
params[:geo_bounding_box][:bottom_right_lon] = @search.ne_lon

Hope you can advise!

1
  • 1
    Arrays need integers as the argument for []. So it is impossible to do that. Commented Mar 18, 2013 at 23:22

2 Answers 2

1

That's a Hash.

params = { 
  :geo_bounding_box => {
    :top_left_lat => @search.ne_lat,
    :top_left_lon => @search.sw_lon,
    :bottom_right_lat => @search.sw_lat,
    :bottom_right_lon => @search.me_lon
  }
}
Sign up to request clarification or add additional context in comments.

Comments

1

Ruby hashes (not arrays) are initialised with {} not [].

params = {}
params[:geo_bounding_box][:top_left_lat] = @search.ne_lat
...

Apart from that you're on the right track!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.