Practical eCommerce

Developer’s Diary Blog Home · F.A.Q.'s

HOME · Tuesday, May 13, 2008

Developer’s Diary

Handle File Uploads Easily in Rails

April 14th, 2008

Recently I have been working with file uploads quote a bit in Ruby on Rails. In the past I have struggled through the process of allowing a user to upload a file (whether it be an image or a PDF file) from a web form. Let’s just say that this represents one of those occasions that I am glad to be using Ruby on Rails, due mainly to a nice little plugin called “attachment_fu” by Rick Olson. This is a file upload plugin that makes the process of uploading files from web forms almost trivial, and makes the uploading, resizing, and thumbnailing of uploaded images much, much easier.

Installation is as simple as typing:

Read the rest of this entry »

Posted in Application Development, Ruby on Rails | 2 Comments »

 

 

Two Birds With One Stone

March 12th, 2008

I wrote a post a while back about the Web 3.0, and how in my opinion such nomenclature could be defined as “the emergence of inter-related services”, if I am allowed to paraphrase in such a way. Partially in defense of my previous post, and partially out of sheer admiration, I wanted to post about the reCAPTCHA project being run by Carnegie Melon University.

First of all, if you aren’t sure what a CAPTCHA is, they are the (somewhat annoying) graphics that appear in some web forms that force you to type in a group of characters to prove that you are human. The idea being (originally) that if you could correctly enter the words that are displayed in an image (which are not readable by robots) then you are a human and your contribution, be it a comment, a forum post, or something like that, should be allowed. The problem is that spammers catch on quick, and OCR, or Optical Character Recognition, software has come a long way. There in lies the problem, or problems, that the folks a Carnegie Melon have gracefully begun to tackle with reCAPTCHA.

Read the rest of this entry »

Posted in General Posts | 2 Comments »

 

 

Useful Rails Plugins

February 20th, 2008

In the process of developing our new site using Ruby on Rails I have come across quite a few plugins that I thought I would share. Of course, there are an endless number of plugins available for Rails, with many more becoming available every day. In case you are curious, a “plugin” is a set of files that adds functionality to your Rails application. Installation of plugins is very simple, as with most things in Rails. You simple type script/plugin install plugin_name from a command line in your application, and the plugin gets installed for you. So without going into too much detail about what plugins are, let’s take a look at some of the plugins that I have found helpful recently:

will_paginate plugin

Pagination was removed from the Rails 2.0 core code, with the developers opting to move pagination functions to plugins instead. The result is that there are many pagination options to choose from, including code it up yourself if you feel like it. I don’t, and prefer to use this plugin. Simply install the plugin, check out the README file included with it, and you are up and running with paginated pages in no time. A nice, very easy way to display multiple pages of data, and not go too heavy on the database while you are doing it.

Read the rest of this entry »

Posted in Application Development, Ruby on Rails | 2 Comments »

 

 

Rails Acts_As_State_Machine Plugin

January 30th, 2008

I realize that I haven’t been posting as much recently, and one of the reasons is that we are getting down to the final build stages of our new website, which should be going live sometime in the next couple of months. Needless to say, and since I am basically the only one working on it, it has been taking up quite a bit of my time. On the plus side, there are lots of things to share. As I have mentioned before, our new site will be built using the Ruby on Rails framework, and I wanted to share my appreciation of Scott Barron’s Acts_As_State_Machine plugin.

This plugin, which for a Rails application can be installed with one simple command, provides an engine for dealing with different “states” of a database record. If you are like me, that might be a little confusing. Basically what it means is that frequently you will have database records that will need to be assigned a certain state, or status. For example, let’s say that you have user records in a database, and that you want to be able to assign certain “states” to users, such as “active” and “suspended”. In the past I have always tackled this with boolean fields in a database, or even an integer field where various numbers represent various states. A “1″ might represent “active”, whereas a zero would represent “inactive”, and so on.

Read the rest of this entry »

Posted in Application Development, Ruby on Rails | 2 Comments »

 

 

iPhone Earphone Troubles

January 17th, 2008

This one is actually quite funny, albeit not terribly related to ecommerce. I had an issue with my iPhone today where the headphones didn’t seem to be registering correctly with the device so that it didn’t seem to know when they were connected and when they were not connected.

The symptoms of this are that the phone would not send any audio signals to the headset speaker or external speakers, and would not pick up input from the headset mic. Rather, it thought that the headphones were still connected to the iPhone and was sending output to and expecting input from the headphones. Kind of problem since you can’t do anything with it then, and it was getting frustrating. I wasn’t sure if it was related, but I had just done a software update, and I also noticed that the headphones didn’t seem to go all the way into the jack, if even only by a tiny bit.

So I set off to Apple’s website to find support, and ran through the routine. One of my favorite suggestions, which is actually backed by Apple, is that you plug in and remove the headphones about ten times, which seems to solve the problem. Actually, this is kind of related to the actual solution, but I don’t suggest this as a viable option. Then there was the classic reset the phone, turn if off and on, and a few other steps that didn’t yield any results.

Read the rest of this entry »

Posted in General Posts | 2 Comments »

 

 

Rails 2.0.2 Defaults to SQLite3

December 31st, 2007

As some of you may have noticed since updated your Rails gems to the new 2.0.2 version, there have been some changes to the defaults. The primary one that will stare many people in the face is that rather than defaulting to MySQL as the database application that Rails uses, it now wants to default to using SQLite3. The Rails core team sums up their decision in this post on the Rails blog, which seems to make sense. After all, being opinionated is what Rails is all about.

However, I still use MySQL, and will probably continue to for a while. I know quite a few people that will also probably continue to use MySQL, which means that when we are generating a new Rails application we will need to start telling Rails that we want to change the database application. This is simple enough, as creating a new application is simply a matter of typing this following into the terminal:

rails applicationName

Of course, this will default to SQLite3, so in order to have Rails generate a new application that will interface with MySQL, we simply add a flag to our command, resulting in:

rails -d mysql applicationName

This will generate a new application that uses the MySQL adapter, just like the default used to be. There are quite a few other changes, so I recommend checking out the Rails blog in order to get caught up. Specifically, there is another new default that will not look for updated templates in production mode. Rather, it will cache views in production mode, meaning that when you change templates on the production server you will also need to restart the application server (Mongrel in most cases) in order for Rails to register the changes.

Posted in Application Development, Ruby on Rails | 1 Comment »

 

 

Accessiblity Information

December 26th, 2007

So I have been banging my head against a wall lately trying to figure out how exactly an ecommerce merchant, or anyone for that matter, determines whether or not they are required to abide by the Americans with Disabilities Act with regard to their websites. We have done some articles recently on accessibility, and it remains one of my interests. With that in mind, and having read as much as I think I can about it, here is what I have come up with. Keep in mind that this is not legal advice, or anything close to it.

First of all, the ADA provides protections for Americans with disabilities, ensuring that they are not denied access to employment and services based solely on their disability. For the most part, every employer is aware of their obligations under the ADA with regard to their employees, and if you aren’t, the I highly recommend giving the ADA a read. However, I am more interested in how websites play into things. Particularly since the highly publicized lawsuit brought against Target because their website was not accessible. Most recently the lawsuit was given class-action status which sets one of the first legal precedences in this matter. I suspect that there will be many more, based on the following.

Read the rest of this entry »

Posted in Website Design, General Posts | 3 Comments »

 

 

Rails 2.0 Has Been Released!

December 11th, 2007

I’m certainly not the first person to put this information out there, but for anyone that has been following this blog for Rails information should be aware that the newest version has been released. Rails 2.0 boasts a series of new features and improvements, most of which appear to me to be under the hood more than right in your face. Most notable to me are the following changes and new features:

1. View template file name changes.
In order to more accurately reflect what Rails is doing, all generators will now use a new naming convention with regards to view templates. In the past a view file might be called something like “articles.rhtml”, which would denote that an HTML view is to be rendered. In an effort to separate out the MIME type and the renderer of the view, the new naming convention will use names such as “articles.html.erb”. In this example, you can see that the file name shows a MIME type of HTML, and that the ERB renderer should be used to render the output. What would previously have been “articles_rss.rxml” would now be called “articles_rss.xml.builder”, telling us that the MIME type will be XML and that Rails will use the Builder renderer to show the view. Older template file names will still work until Rails 3.0 is released, so this one is going to be a phased transition.

Read the rest of this entry »

Posted in Application Development, Ruby on Rails | 3 Comments »

 

 

Lightbox Gone Wild

December 3rd, 2007

Recently I have been working on our new website, and one of the interface challenges that I have been facing has been modal windows, or windows that block input to other areas of the page until someone closes them. A good example that we are all probably familiar with is JavaScript alert boxes. These are the alert and confirmation windows that appear over your web browser (or sliding out of the top) when a warning is triggered or you are required to provide input. Go to our home page on this site and try to search for a blank term, and you will see what I am talking about.

JavaScript modal windows have their time and place. They are pretty limited in general, and I wanted some way to provide a modal window that will behave much more like a traditional pop-up window. The answer for me was with Lightbox Gone Wild, which is a great JavaScript and CSS creation by the very Chris Campbell over at ParticleTree. Based on the original lighbox.js by Lokesh Dhakar, this group of scripts that is based on the prototype JavaScript library makes creating a clean, browser compatible modal windows very simple. Not only that, but as the name suggests, it provides a clean “lightbox” effect for the content loaded in.

My experience with Lightbox Gone Wild has been positive so far. I agree with Chris, the author of the Gone Wild version, that the original Lightbox.js is a bit limited in it’s abilities, and when comparing the two I am impressed with how flexible the Gone Wild Version is. As a developer is is unobtrusive, required only that the scripts be linked to, and CSS classes be added to markup to add functionality. There are plenty of options, including the placeholder that is displayed while the real lightbox content is being loaded in. Oh, and did I mention that also does not break any accessibility guidelines?

Personally, I have been impressed. I’ve been trying very hard to keep an eye on accessibility and separation of content, formatting and functionality as I develop the new site. Additionally, usability is high in mind, and with tools like Lightbox Gone Wild out there, I am able to work much more efficiently.

Posted in Website Design, JavaScript | 2 Comments »

 

 

Using iFrames in xHTML 1.0 Strict

November 26th, 2007

Just kidding… you can’t. But it’s a good title for a blog post since if you run into the problem that I ran into, you probably searched for that. The reality is that iFrames are a bad idea, and have been for years. The harsher reality is that they are not allowed at all in xHTML 1.0 Strict, meaning that either a browser will not even display it (which is probably the better option) or it is displayed but causes your code to not validate. Usually this never comes up, since we usually just assume that frames are bad and to avoid them.

But what about when you need to upload some images and you want to do it without updating the page? Ajax does not allow for file uploads, so that is not an option. A good example of this is a Wordpress interface when you are creating a new article. In order to allow someone to upload an image for placement in their post, there is an iFrame there to accomodate that. At least in my installation, I wouldn’t be surprised if they have upgraded that part. Either way, I want our editorial staff to be able to upload images when they are composing articles without having to refresh the page (and potentially destroy their edits). An iFrame is not an option since I am taking great care to make sure that this application is XHTML 1.0 strict, and also compliant in the Big Four browsers.

Read the rest of this entry »

Posted in Website Design, Application Development | No Comments »

 

 

Brian Getting

Brian Getting is the Online Director at Practical eCommerce, specializing in website design and application development.

Calendar

May 2008
S M T W T F S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

Browse blog posts by category.

RSS Content Feeds

Ecommerce Articles

Browse All Articles
Browse our complete archive of ecommerce articles.
Accounting, Management & Legal
Ecommerce articles related to managing a small business including ecommerce accounting, business strategy and legal considerations.
Conversion & Usability
Online business articles about converting web site visitors into customers and how to gauge and improve your business website's usability.
Development & Programming
Articles to help designers, developers and programmers create successful, search engine friendly ecommerce websites and improve existing ones.
Hosting, Infrastructure & Software
Articles for ecommerce businesses about ecommerce web hosting, business infrastructure, business strategy and helpful ecommerce & small business software.
Interviews & Profiles
Interviews with prominent ecommerce business personalities and profiles of successful online businesses.
Inventory & Shipping
Ecommerce articles about inventory management, ecommerce order fulfillment and product shipping considerations.
Marketing & Revenue Growth
Articles relating to online marketing, email marketing and using the Internet to growing your business.
Search Engine Optimization
Search engine optimization articles for ecommerce business owners, strategists, marketers and developers.
Shopping Carts & Online Payments
Articles covering ecommerce shopping cart platforms and options for choosing an online payment gateway.
Training & Education
Tutorials and articles providing training and education for ecommerce business owners and developers of ecommerce websites.

Search Articles

Ecommerce Community

Ecommerce Blogs
Read our blogs about ecommerce topics written by industry professionals.
Community Forum
Connect with other ecommerce professionals to trade advice and answers in our community forum.
Podcasts
Check out our ecommerce podcasts covering topics ranging from interviews to tutorials.
RSS Content Feeds
Subscribe to our RSS feeds and have fresh ecommerce content delivered to you.

Ecommerce Resources

Free Email Newsletter
Sign up for Ecommerce Notes, our free email newsletter for ecommerce business owners and developers.
Ecommerce Directory
Browse our directory of ecommerce products and services, or submit your own listing in our directory.
Ecommerce Glossary
Familiarize yourself with terminology or submit terms to help others with our Ecommerce Glossary.
Events Calendar
Find out about upcoming ecommerce events or invite other ecommerce professionals by posting your own event.
Press Releases
Browse ecommerce related press releases and post your own press release for distribution.
Ecommerce Store & Back Issues
Pick up back issues of Practical eCommerce magazine along with other merchandise from Practical Ecommerce

About Practical eCommerce

Frequently Asked Questions
Look at frequently asked questions regarded using our website, subscribing to our magazine and more.
Advertising Information
Information about advertising in Practical eCommerce magazine, on our website, or in our email newsletters.
Editorial Sharing
Learn about options for sharing our content with your visitors, customers or employees.
About Us
Learn more about Practical Ecommerce magazine and meet our staff.
Contact Us
Contact Practical Ecommerce at any time for more information. We'd love to hear from you.
AdvertisementStone Edge TechnologiesEndiciaBDXI

Copyright 2007 Confluence Distribution, Inc. and Practical eCommerce.
All Rights Reserved.

Privacy PolicyConditions of UseContact Us