opinions and rants on software and...things
December 07, 2008
A few posts ago, I promised to share my fail-proof instructions for installing and integrating the Ruby on Rails plugin called acts_as_urlnameable. Here is what I learned. Since I put this together, I have discovered some more issues that I need to find workarounds for, and I'll post about those later. For now, here's how you get it working for you in the vast majortiy of cases.
1. Install plugin:
- script/plugin install http://code.helicoid.net/svn/rails/plugins/acts_as_urlnameable/ will make a static copy of the source for you, or
- script/plugin install -x http://code.helicoid.net/svn/rails/plugins/acts_as_urlnameable/ will fetch a copy via SVN
2. Add acts_as_urlnameable to //environment.rb// if needed. If you define config.plugins, add urlnameable there.
3. For each model that will be urlnameable, add acts_as_urlnameable:
class Foo < ActiveRecord::Base acts_as_urlnameable :nameable_field end
4. Add to each Model an override of to_param. This implementation differs from the suggested ones by continuing to provide the default numeric id for records that haven't been urlnameified yet. This should help you to avoid breaking existing functionality when adding this to an existing website:
def to_param if urlname and urlname.length ...read more
December 05, 2008
I have just uploaded siginifcant changes to the taggable-mixin code base. The new version has a markedly-simplified API and substantially-improved performance. The cost of this goodness is that it is not backwards-compatible with the previous release, version 1.0. Applications that have already started using Taggable-mixin will have to undertake conversions of their codebases and datastores.
Interested programmers should download the current code base and look through the documentation file, taggable.html.
I will answer any and all questions, comments and criticisms made here in the comments or sent to my email address.
December 01, 2008
3/3/2001: I now consider the information in this post to be obsolete. More useful and up-to-date advice is available in the post Do Not Reinvent the Pagination Wheel.
In creating this blogging software, I have had to come to grips with finding a way to paginate content. It's a relatively trivial exercise under most circumstances; it is a well-understood pattern, and it is actually built in to some of the popular frameworks. AppEngine is a little different, and the nature of the Datastore actually makes it rather challenging to implement efficient useful paging. I've come up with a solution that I think makes for a good balance of functionality and AppEngine-friendliness.
The code and tehcniques included here are Open Source. I do hope that if you choose to use this code in your oen project that you'll comment here to share your feedback, suggestions and experiences. Sharing means caring, guys. For real.
This Paginator class depends on the Model that it will be paginating having an 'index' field, a unique value that is order with respect to how the pagination will occur. For instance, here is the model definition for this blog's Comment entity ...