0

I'm attempting to test a sample project at

http://162.243.232.223:3000/api/query

This is a rails project.

The rails controller is looking for a params hash like params[:query]['input']

In javascript, I am using jquery like this:

$.get('http://162.243.232.223:3000/api/query') 

which get the expected default output.

However, I'd like to send in my own params more along the lines of this:

$.get('http://162.243.232.223:3000/api/query', { 'input': 'my_input' })

However, for whatever reason, this is returning errors, the

{ 'input': 'my_input' }

argument is not being passed as

params[:query]['input'] 

into Rails.

Any ideas on how I could start getting non-default responses back from Rails?

Thanks

2
  • Open up your console and take a look at what URL is actually being fetched by the browser; this will let you know which side the problem is on Commented Jul 25, 2014 at 18:56
  • does your server-side rewriting support arbitrary arguments like that? just because you slap any extra key=value pairs into a query string you want doesn't mean it'll actually make it through to your code on the server. Commented Jul 25, 2014 at 18:59

2 Answers 2

1

The way you have it now you would access it simply with params[:input]. The params hash gets all path, get and post variables in a single hash.

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

Comments

0

In some cases when the server is not getting the input params like this how you had mentioned you need to apply this instead:

$.param({
        json: JSON.stringify({
            'input': 'my_input'
        })
    });

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.