0

I am trying to use the following code to convert a hash of options (e.g. { :opt1 => 'a', :opt2 => 'b' } ) into parameters to be appended to a URL (e.g. example.com/page?opt1=a&opt2=b):

ActionController::Routing::Route.new.build_query_string(options)

where options is the hash. I get the following error:

wrong number of arguments (0 for 7)

The corresponding docs show that the initializer method for Route take no arguments, but I think they haven't been updated for Rails 3 yet. I know routing has seen a big update for Rails 3, so I assume this code is for Rails 2.x. Does anyone know what the Rails 3 way of doing this would be?

Thanks

1 Answer 1

1

Never mind - I found the answer.

Rails provides a Hash#to_query method (and for some other types too I think).

Somehow Google did a poor job of finding this for me!

Sign up to request clarification or add additional context in comments.

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.