For Spree 2.2 (not 2.1), use the following code in initializers/spree.rb:
Spree::Image.attachment_definitions[:attachment][:url] = ':path'
Spree::Image.attachment_definitions[:attachment][:path] = '/spree/products/:id/:style/:basename.:extension'
The rest of the configuration should be set as 2.1 (see here for details).