PullMonkey Blog

Web Name: PullMonkey Blog

WebSite: http://www.pullmonkey.com

ID:315369

Keywords:

PullMonkey,Blog

Description:


Home

PullMonkey Blog

11 Aug

Dynamic Select Boxes – Ruby on Rails 3


Over 4 years ago, I wrote a tutorial for doing dynamic (cascading) select boxes.
Still getting comments and emails to this day. Mostly asking how to get this working with rails 3, which has moved from prototype to jquery.
So here's a tutorial for getting 3 select boxes to trigger updates for each other.

First set things up:

I just used the html5 haml twitter bootstrap, etc template. Really useful.

If you need data, here's what I used - put this in your db/seeds.rb file:

Next, setup your model associations:

Genres have many artists.
Artists have many songs.
Genres have many songs through artists.

I'm just using a home controller to setup variables for the index page as well as setup variables for use in the dynamic updating:

Now the view just has the 3 select boxes and the unobtrusive javascript (triggered onchange) to make the ajax calls for updating:

We need our rjs files for updating the select boxes, one for the songs (when artist changes) and one for the artists and songs (when genre changes):

Our routes are simple:

That's it.

UPDATE: Here's an erb alternative for index.html.

And the js.haml can be converted to js.erb by taking #{...} and converting to <%= ... %> :


12 ResponsesFiled under: development, Javascript, rails, ruby, tutorialsTags: cascading select boxes, dynamic, dynamic select boxes, jquery, rails, rails 3, select boxes, unobtrusive javascript
04 Aug

VIN API – Do you know about the complete data set?


Looking at our data trends for VIN API, we show about 15% of all requests are for the complete data set. It's the same price as the basic data set and rich with a ton of data.

Check out the data set from this post over 1 and half years ago. On top of the basic data set's year, make and model, the complete data set comes with data like MSRP, MPG (city and highway), dealer invoice, gas tank size, etc.

We get tons of hits for basic data, but at no additional charge we also provide the complete data set. Just add a complete
=> "true" to your request. So simple and there's no performance hit.

For more information, check out or examples and faq.

Enjoy!

Here's another look at the data elements from a comprehensive query:


Comments Off on VIN API – Do you know about the complete data set?Filed under: api, business, development, projects, rails, rubyTags: basic data set, complete data set, fun, rich data, ruby, tutorial, VIN, vin api
27 Jul

Using Ruby to read from a MagTek USB Card Reader


Been playing around with a lot of USB devices lately, to get them to play nicely with some of our touch screen Rails apps.
One of the devices is a card reader - specifically a MagTek reader, and the same code works for the ELO reader.

I've tried a billion different ways to ensure we're reading in all the data. At first, I was just asking the usb stream to present me with a certain number of characters, b/c that's how all the examples do it.
But we're using a lot of different cards with the readers, so that didn't work too well. So now I just read one character at a time until we find the new line.
Here's the code to find the device, open it, close it and read from it, all whilst finding and converting the data as required.

So using this code, we take the swiped data and send it to our server for storage.


Comments Off on Using Ruby to read from a MagTek USB Card ReaderFiled under: development, Linux, projects, ruby, tutorialsTags: card reader, card swipe, curb, httpi, magtek, ruby, USB
26 Jul

Signature Pad in Linux


I'm using the topaz model T L462 HSB. It's nice now that it works. But what a PITA to get it going. The biggest problem with the device is the documentation. There is no low level documentation explaining the representation of the bytes coming in over usb. So you are stuck using their libraries which expose some poorly explained API.

Anyway, like I said, great when it works. So I'm working in linux which basically leaves me having to use java libs and a shared object file.

Here's my code:

It sits and waits until the sig pad gets some points on it. Once we have points it waits for a lapse in time where there is no change in the number of points.
Once we've decided that we have captured a signature, we store it to a file.
Then we shell out to a ruby script - see the httpi and curb article - which is how I get the file to our rails server for display and verification from the user.

Now, you'll need a few files. Most of which can be found in the java zip download from the vendor site.
From that zip, you should grab the following:
SigPlus2_60.jar
RXTXcomm.jar
libSigUsb.so - if you need the 64 bit version, go here - http://www.topazsystems.com/Software/libSigUsb7242012.zip

Then I just used eclipse to set everything up and build. Works well so far.
The only thing you may need to change is the model (I have mine set to SignatureGem1X5) and com port (I have mine set to HID1).


Comments Off on Signature Pad in LinuxFiled under: development, Linux, projects, tutorialsTags: HSB, java, signature pad, topaz, USB
25 Jul

Using HTTPI with Curb to do multipart file uploads with spnego


It took a while to find a library that handled spnego requests, as opposed to shelling out to a curl --negotiate. Found httpi to work well with the curb adapter.
The problem was that the documentation didn't really explain how to do file uploads withing the httpi request block.
Wasn't too much of a big deal, but I thought it may save someone else some time.


2 ResponsesFiled under: development, Linux, ruby, tutorialsTags: curb, curl, file upload, httpi, multipart upload, negotiate, spnego
30 May

Rubygem version incompatability with older Rails versions


We maintain a rails 2.3.8 application and haven't had to touch it in quite some time. But when we did, we came across this error:

uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

Then after applying the solution found here, we started getting this error:

undefined method `name' for "actionmailer":String (NoMethodError)

Both errors were resolved by using RVM to specify the rubygem version best suited for this application.

rvm rubygems 1.3.7

So our .rvmrc file now looks like this:

rvm use @rvm rubygems 1.3.7

Comments Off on Rubygem version incompatability with older Rails versionsFiled under: development, rails, rubyTags: incompatability, rails, ruby, ruby on rails, rubygems
26 Apr

Headers and Footers in ruby’s Spreadsheet gem


Have you ever needed to add a header or footer to your spreadsheets in ruby?
Yah, well, we have

TAGS:PullMonkey Blog

<<< Thank you for your visit >>>

Websites to related :
Ryan Castellucci’s blog | rya.n

  rya.ncRyan Castellucci’s blogPostsAboutContact my profile on Twittermy profile on GitHubmy profile on LinkedInemail me DKIM: Show Your PrivatesIf you

Design Stack: A Blog about Art,

   ShopContactSubscribeAdvertisetable#dsheader{margin-left: -40px;margin-top: 0px;margin-bottom: 20px;background-color: white; width: 930px;height: 60px

a sibilant intake of breath — M

  HomeAbout meAcademic C.V.Contact meProjectsMy photosMy travelsCopyright infoSite rulesPhD thesisMy blogsMy wikia sibilant intake of breathTeaching in

Urban Survival - Podcast & Blog

   skip to Main Content Recent ITRH Survival Podcast EpisodesE300: The Final ITRH Podcast Episode (for now)Tune in for the final episode and hear Aar

Ellopos Blog

  ELLOPOS BLOG English / Ἑλληνικά The Bible Greek Language Greek Literature Plato Meister Eckhar

Blog - IM CERTIFIED® BLOG

  Math CurriculumIM Certified® MathIM K–5 Math™IM 6–8 Math™IM 9–12 Math™Professional LearningResourcesBlogNew Blog PostsGrades K–2 MathGrades 3

Blog Người Nuôi Yến

  Trang chủKỹ thuật nhà yếnGia công yếnChế biến tổ yếnLinh tinhNuôi yến không chỉ là đam mêTrang chủKỹ thuật nhà yếnGia công yế

Văn Linh - Blog Chia Sẻ Thủ T

  open ]-->Bình luận .st0{fill:#4C4C4C;} .drK .st0{fill:#C7C7C7;} Thông báoBảo trì và cập nhật blog(2)February 1

giahuyblog.com - 

  

Thiết kế blogspot chuyên nghi

  Trang chủChuyên mụcThiết kế blogspotThủ thuật blogspotTiện ích blogspotSeo blogspotTheme blogspotThiết kế contact formTiện íchNén & Làm

ads

Hot Websites