Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Barcode detection in rails app...

Replytotopic

Barcode detection in rails app

Posted in Forums : Ask a Rails expert

 
Profile

Authority 12
Posting Rating 89
Sign in to rate this post

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 ?

 
Profile

Authority 37
Posting Rating 85
Sign in to rate this 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

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

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

 
Profile

Authority 12
Posting Rating 89
Sign in to rate this post

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.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this 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?

 
Profile

Authority 12
Posting Rating 99
Sign in to rate this post

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.

Replytotopic

Other Recent Topics

Ask a Rails expert : Tracking down an issue

Ask a Rails expert : Thread Vs Transaction

Ask a Rails expert : implementing whitelist plugin

Ask a Rails expert : Validation helper

Ask a Rails expert : FILE EDIT/DELETE

Ask a Rails expert : decrypting the password

Ask a Rails expert : Static Objects in Rails

Ask a Rails expert : Newbie - Rake Cant Execute Test

Ask a Rails expert : Call Web service

Ask a Rails expert : RMagick issues

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel