passing html params in Ruby

J

joep

I have an AJAX page that I built.
The user enters in some info.
I format a query string and want use it to query my DB.

something like this:

var query_string = "SELECT * FROM mydbtable;

<%
require 'dbi'
require 'cgi'
cgi = CGI.new
params = cgi.params

new_query_string = cgi.params['query_string']

dbh =
DBI.connect("dbi:pg:dbname=blank;host=blank;port=blank","blank","blank")

newsth = dbh.execute("#{new_query_string}")

rows = newsth.fetch_all

%>

the query_string variable is not passed in the 'params', so obviously
this code is never going to work.
How do I pass the formatted variable (query_string) into my embedded
ruby code so that I can query my DB?

Thank you in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top