I would like to search my DB for records using a Model.where
request... Using jquery I have access to the text within the select
option chosen from a drop box. Now, if only I could take this text and
assign it to a ruby instance variable, such as @brand.... I could then
insert the value into the 'where' request and pull the records
corresponding to the selected option.
It seems possible to assign a ruby variable to a jquery var, but not
the other way around. Is there, or could there be, a ruby function to
help with this?
I would like to search my DB for records using a Model.where
request... Using jquery I have access to the text within the select
option chosen from a drop box. Now, if only I could take this text and
assign it to a ruby instance variable, such as @brand.... I could then
insert the value into the 'where' request and pull the records
corresponding to the selected option.
It seems possible to assign a ruby variable to a jquery var, but not
the other way around. Is there, or could there be, a ruby function to
help with this?
Have a google for Ajax request. You will need to respond to an xhr request in your controller and return whatever result you need in Rails. From the jQuery (JavaScript) side, you're doing a post request, just not refreshing the page as you do so.
@Abram is this actually what you are wanting to do, or are you just
trying to get a value from a variable in your jQuery code in the
browser passed as a parameter in a request to the server in order to
use it in a db lookup?