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.
Barcode detection in rails app
6 Posts
Barcode detection in rails app

In my application a hand scanner scans the barcode and sends the isbn13 as search parameter.Controller should receive this signal and search for the entered value.Basically, when a scanner signal is recieved a search for item id should performed.How can we implement this in rails, is there any library available in ruby ?

Person
Forum Rating: 100
Sign In To Rate Post

There are several libraries for generating barcodes, but I can't find one for reading barcodes. Doesn't the scanner do the reading for you?

"Barcodes on RubyForge":http://rubyforge.org/search/?type_of_search=soft&group_id=796&words=barcode

If your scanner is connected to the client PC, and Ruby on Rails is running on the server, then your problem isn't really a Rails problem. You need some way of making the scanner submit data to the server when it scans a barcode.

The absolute simplest way would be to just have a text field on a form. If that field has focus and you scan a barcode, it will type in the barcode data into the field. You could then submit the form normally. Your barcode scanner might even have a setting that makes it output a carriage return keycode after the barcode data, which would automatically submit the form. Also when the page first loads you could use a bit of javascript to automatically set focus to the text field.

If you can't use a simple form for some reason, the scanner might come with some sort of activex / flash / java plugin which you could embed on a page. That way looks potentially more complicated though, also platform specific (especially if it's activex).

Jon

Thanks for your replies

I would also like to get help on how we can have a listener monitoring the port where the scanner signal will be available and collect the barcode and send that as an input to the search field.

Person
Forum Rating: 100
Sign In To Rate Post

Most scanners these days just emulate a keyboard, i.e. when you scan something, to the PC it looks like you just typed in the bar code number on a keyboard.

What make / model of barcode scanner are you using? Could you give us a URL to more info?

Jon's first reply is the best solution in my experience. The bar code scanner will submit a tab or carriage return after scanning so a form can be easily submitted after scanning. I've enhanced the experience somewhat with simple javascript to default focus to the required field on load and other simple things like redirections or new windows when appropriate.

Consider the users and K.I.S.S. on the front end I say. You can get as fancy as you want on the server side after that.

6 Posts
Login to add your message