Archive for October, 2008

Extension Tip: Using Migrations for your Configuration

October 28 2008 by railsdog

Spree comes with all sorts of default configurations that you will likely want to customize. Many of these values can be changed now through admin screens (those that can’t be changed will be able to shortly once those screens are written.) Once a preference is changed from its default, the value is stored in the database.

It is possible to use a migration to setup these preferences so that you can set the preferences of your site automatically. This is handy when migrating a new series of configurations from a tested development environment to production. You no longer have to remember to manually change these settings, just run the migrations like normal.

For example, the default country in Spree is United States. If you wanted the default country to be Ireland you could add the following to your site extension:

class AddCustomConfigurations < ActiveRecord::Migration
  def self.up
    Spree::Config.set(:default_country_id => 96)
  end

  def self.down
  end
end

Migration Generator for Extensions

October 22 2008 by railsdog

Extensions have always provided a handy generator for migrations that took care of the new model case. If you had a foo_extension and wanted to create a bar model you could always use:


script/generate extension_model foo bar

This would yield the following:

exists  app/models/
exists  spec/models/
create  app/models/bar.rb
create  spec/models/bar_spec.rb
create  vendor/extensions/foo/db/migrate
create  db/migrate/20081022232711_create_bars.rb

That works most of the time but if you decide to further modify the foo table (or if you need a migration unrelated to a specific model) then you’re pretty much stuck. What would be really handy is a generator that generates additional migrations for an extension using the current timestamp that standard migrations receive.

Thanks to a brand new edge feature, this is now possible.

script/generate extension_migration foo add_foo_property
This now gives you the desired migration:
exists  vendor/extensions/foo/db/migrate
create  vendor/extensions/foo/db/migrate/20081022232740_add_foo_property.rb

Upcoming Features: Shipping and “Near Static” Content

October 21 2008 by railsdog

There are two interesting features that are in the works for the upcoming version of Spree. The first major new feature is a basic shipping framework that is designed to support almost any conceivable method of shipping. The basic idea is that extensions will be able to provide their own shipping “calculators” which can be plugged into this framework.

The next version of Spree will likely ship with several calculators included. There will be some basic implementations in the core such as flat rate shipping. Brian is working on a cool extension that calculates shiping using predefined amounts. We’re also hoping to support USPS and UPS shipping by providing calcualtors that will wrap the active_shipping gem.

We’ll have a lot more to tell you about as the feature develops. For those of you who are interested in getting a sneak peak, please see the shipping branch.

The second feature to tell you about is support for what we call “near static” content. By near static, we mean content that is mostly just html but needs to be presented within a reusable layout. It may or may not also have need for helpers or other minor Ruby templating. The main thing to keep in mind is that we’re not talking about typical Rails views that iterate through instances of Active Record.

Think of near static content as basically the “brochure” parts of a commerce site. Many commerce sites have such content and we wanted to come up with a way to organize the content without resorting to a bunch of controllers for simple pages that just needed SEO friendly URL’s. So here’s a quick solution to this problem that we wanted to get some feedback on. You can either cherry pick this commit or simply checkout the static-content branch in github.

Fair warning, these features are rough and incomplete. The fact that they are on their own branches indicates that they are currently too rough to even be considered “edge.” Think of them as “edge plus.” That said, you should check them out if you have an urgent need or if you are just curious.

Spree 0.4.1 Released

October 14 2008 by railsdog

Spree 0.4.1 has just been officially released. This is a minor patch improvement to the previous 0.4.0 release. The release includes a few important bug fixes related to the use of extensions.

The routing problems in extensions are now fixed. Its also now possible to run the specs for your custom extensions within your project. Special thanks to Edmundo for providing the extension fixes.

Spree 0.4.0 Released

October 2 2008 by railsdog

Spree 0.4.0 has now been released. We have decided to jump version numbers in order to avoid possible confusion with developers who have already installed an “edge” version of the source locally on their machine as version 0.3.0. Going forward, the edge version of the source will be considered 0.4.99 and any patch releases to this version will be considered 0.4.1, etc. This is basically the same approach taken by the Rails project.

The current release of Spree contains many significant improvements from the previous 0.2.0 release. Some of the highlights include:

  • Rails 2.1 support
  • SEO improvements
  • Security enhancements
  • Public assets for extensions
  • Mailer templates for extensions
  • VAT inclusive pricing
  • Taxonomy

We’re looking forward to seeing some of the great third party extensions for Spree which are being written as you read this. The Paypal Website Payment Standard extensions is also currently being overhauled to be compatible with the new release.

Spree 0.4.0 requires Rails 2.1. It is not yet compatible with Rails 2.1.1 due to some issues with the resource_controller plugin. Enjoy the new release!

Taxonomies Are Here!

October 1 2008 by railsdog

In preparation for the upcoming 0.4.0 release we’ve just checked in a version of the new Taxonomy based categorization system. This provides a simple, yet robust way of categorizing products by enabling store administrators to define as many separate structures (taxonomies) as needed, and to link products to multiple nodes (taxons) from each taxonomy.

The sample store includes a basic implementation of the taxonomies system to structure products by Category and Brand. We’ve also added some more details on this to the wiki.

We’re keen to get your feedback on this important new feature, so please checkout the latest source and let us know what you think!