Dynamic Graphics with Rails 1.2
Dynamic Graphics with Rails 1.2 | Ruby on Rails for Newbies
The upcoming release of Rails 1.2 has some nice features for creating dynamic graphics in your application. Here we have a simple shopping cart icon (purchased and modified from the Iconfactory). I want to show the number of items in the cart. I could manually create a series of graphics with each number, but that seems inelegant. Anytime the icon needed tweaking, I would have to regenerate all the icons.
Rails 1.2 has the ability to send different types of content from the same action. Basically, I just want a graphical representation of the shopping cart. I’ll use the Cart#show action to render a graphic if it is accessed with a “png” extension. Otherwise, it will show the shopping cart items, total price, and checkout button in HTML.
