<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>spec/from_param_spec.rb</filename>
    </added>
    <added>
      <filename>spec/schema.rb</filename>
    </added>
    <added>
      <filename>spec/spec_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,11 +1,17 @@
 FromParam
 =========
 
-This plugin is a tiny addition to ActiveRecord::Base that establishes a better 
+This plugin is an addition to  ActiveRecord::Base that establishes a better 
 convention for finding records based on parameters. It adds a &quot;from_param&quot; class
 method to ActiveRecord::Base as a convention for fetching a model from a URL
 parameter. By default it will find a record based on the to_i of the passed in
-parameter, but the real use is by overriding it.
+parameter, but storing a parameter in a column is where it becomes especially useful.
+
+If you create a 'param' column in your table (or any other column using set_param_column),
+the to_param of your record will automatically be saved to that column whenever
+you save the record, and you will be able to retrieve it using just a simple
+Model.from_param call with the generated to_param. It is probably wise to add an index
+to the param column if you use one.
 
 It's time to move away from generated-key-dependence, and this plugin is an attempt
 to make that easy, painless, and work easily within the existing systems.
@@ -16,31 +22,35 @@ Example
   # default behavior
 
   class User &lt; ActiveRecord::Base
-  
+    def to_param
+      &quot;#{id}-#{first_name.downcase}-#{last_name.downcase}&quot;
+    end
   end
   
   class UsersController &lt; ApplicationController
-    # GET /users/1
+    # GET /users/1-bobby-mcfarin
     def show
-      @user = User.from_param(params[:id]) # =&gt; &lt;User id=1 login=mbleigh&gt;
+      @user = User.from_param(params[:id]) # =&gt; &lt;User id=1 first_name=&quot;Bobby&quot; last_name=&quot;McFarin&quot;&gt;
     end
   end
   
-  # overriding
+  # using a 'param' column, in this case 'slug'
   
-  class User &lt; ActiveRecord::Base
+  class Post &lt; ActiveRecord::Base
+    set_param_column &quot;slug&quot; # defaults to &quot;param&quot;
     def to_param
-      login
-    end
-    
-    def self.from_param(parameter)
-      User.find_by_login(parameter)
+      &quot;#{created_at.strftime(&quot;%Y-%m-%d&quot;)}-#{title.gsub(&quot; &quot;,&quot;-&quot;).downcase.gsub(/[^a-z0-9-]/,&quot;&quot;)}&quot;
     end
   end
   
-  class UsersController &lt; ApplicationController
-    # GET /users/mbleigh
-    @user = User.from_param(params[:id]) # =&gt; &lt;User id=1 login=mbleigh&gt;
+  class PostsController &lt; ApplicationController
+    # GET /posts/2008-04-26-from-param-plugin-released
+    @post = Post.from_param(params[:id]) # =&gt; &lt;Post title=&quot;From Param: Plugin Released&quot; created_at=&quot;2008-04-26&quot;&gt;
   end
+  
+Resources
+=========
+
+Lighthouse: 
 
 Copyright (c) 2008 Michael Bleigh, released under the MIT license</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1 @@
-require 'from_param'
-ActiveRecord::Base.send :include, FromParam
\ No newline at end of file
+require 'from_param'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,52 @@
-module FromParam
-  def self.included(base)
-    base.extend ClassMethods
-  end
-  
-  module ClassMethods
+class ActiveRecord::Base
+  # Class Methods
+  class &lt;&lt; self
+    # The column that is currently set to be used with
+    # the from_param method.
+    def param_column
+      &quot;param&quot;
+    end
+    alias :param_column= :param_column
+    
+    # Allows you to set the column that will be used
+    # by from_param by default.
+    def set_param_column(val)
+      define_attr_method :param_column, val
+    end
+
+    # Returns true if the param_column is one of the
+    # currently defined columns of your table.
+    def param_column?
+      column_names.include?(param_column)
+    end
+    
+    # Takes a parameter generated by to_param and
+    # tried to find a matching record. If param_column
+    # is set and exists, uses that as the finder, otherwise
+    # uses the id such as in the default Rails to_param.
     def from_param(parameter)
-      find(parameter.to_i)
+      if param_column?
+        send &quot;find_by_#{param_column}&quot;, parameter
+      else
+        find_by_id(parameter.to_i)        
+      end
     end
   end
+  
+  # Calls param_column? on the class
+  def param_column?
+    self.class.param_column?
+  end
+  
+  # Calls param_column on the class
+  def param_column
+    self.class.param_column
+  end
+  
+  before_save :set_param
+  # Automatically called before saving, sets
+  # the param_column to the current to_param
+  def set_param
+    send &quot;#{param_column}=&quot;, to_param if param_column?
+  end
 end
\ No newline at end of file</diff>
      <filename>lib/from_param.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>722c4c7b276501ff3db10f2a59b0d197f9f7e59f</id>
    </parent>
  </parents>
  <author>
    <name>Michael Bleigh</name>
    <email>michael@intridea.com</email>
  </author>
  <url>http://github.com/ffmike/from_param/commit/0317cb7e6e089d3bfd18546a353fc577c232a4b0</url>
  <id>0317cb7e6e089d3bfd18546a353fc577c232a4b0</id>
  <committed-date>2008-04-26T20:10:57-07:00</committed-date>
  <authored-date>2008-04-26T20:10:57-07:00</authored-date>
  <message>Complete rewrite to include automatic storing and retrieval from a 'param' column along with the default functionality. Should make parameterizing models a snap!</message>
  <tree>14751cf6c4ff2bdfe4ec91521de8a87dc711f093</tree>
  <committer>
    <name>Michael Bleigh</name>
    <email>michael@intridea.com</email>
  </committer>
</commit>
