Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Related record lookups
4 Posts
Related record lookups

I am very new to rails and I have been working on a port of an existing windows app that a wrote a few years ago.

One problem I am having is I do not know how to emulate a related table lookup. In the windows app, a user enters the first few letters of a product code into an invoice line item record. when they press enter a small lookup windows appears with matching products that they would choose one of and then the window closes and the product info gets copied into the invoice Item.

I tried this with a drop down but there are way too many products to be populating the drop down with. What is the best way to handle this?...Thanks!...Dale


I think you might be interested in "simple_auto_complete":http://github.com/grosser/simple_auto_complete/tree/master

Perhaps something like:

class InvoiceController < ApplicationController

  autocomplete_for :product, :code


Thank you Bryan. This looks like what I need. I just need to figure out how to store the associated id from the parent table then is should be exactly what I am needing to do...Dale

The Rails Guides are a great resource. Sounds like you might enjoy "Active Record Associations":http://guides.rubyonrails.org/association_basics.html

4 Posts
Login to add your message