ruby on rails - How do i populate a select with a db call based on another select -
i have form whereby dropdown 2 populated result of selection made in select dropdown 1. if dropdown 1 one had options a, b & c (separate call database) if select application variable , populate dropdown 2 returned results.
i thinking done in number of ways have not quite figured out direction take. first approach going take perform calls straight away , add values associated a, b , c dropdown 1 when activated additional values populate dropdown 2. additionally trying figure how fire http call dynamically based on user hitting first select.
can give pointers how achieve this.
edit
an example of how perform http gets
def get_call(routepath) started_at = time.now enc_url = uri.encode("#{settings.abacus_service_endpoint}#{routepath}") uri = uri.parse(enc_url) http = net::http.new(uri.host, uri.port) req = net::http::get.new(uri.request_uri, get_header_for_abacus_service) resp = http.request(req) logger.bench 'service - get', started_at, routepath return resp if response_ok?(resp) end
have tried looking @ rbates railscast on dynamic select menus. if havent please @ it. in railscast populates states/provinces depending on selected country, if sounds want achieve them here link.
http://railscasts.com/episodes/88-dynamic-select-menus
hope helps you.
Comments
Post a Comment