This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 8f476b6c333539785239274231c4e70044647d8d
tree 8ca0d8273b174947f1b9c200723b7318dd971af3
parent 685f1abb107ee3ba08f29e93641bb9f7064f39f9 parent 4e809e60787e3fb7fa81ffecb2fb8bcd3439925f
tree 8ca0d8273b174947f1b9c200723b7318dd971af3
parent 685f1abb107ee3ba08f29e93641bb9f7064f39f9 parent 4e809e60787e3fb7fa81ffecb2fb8bcd3439925f
| name | age | message | |
|---|---|---|---|
| |
README | Wed Dec 19 11:01:22 -0800 2007 | [joshuabates] |
| |
Rakefile | Wed Dec 19 11:01:22 -0800 2007 | [joshuabates] |
| |
init.rb | Wed Jan 30 23:50:33 -0800 2008 | [joshuabates] |
| |
install.rb | Wed Dec 19 11:01:22 -0800 2007 | [joshuabates] |
| |
lib/ | Sun Feb 10 21:14:45 -0800 2008 | [joshuabates] |
| |
tasks/ | Wed Dec 19 11:01:22 -0800 2007 | [joshuabates] |
| |
test/ | Fri Feb 08 15:50:22 -0800 2008 | [joshuabates] |
| |
uninstall.rb | Wed Dec 19 11:01:22 -0800 2007 | [joshuabates] |
README
ActsAsUrlParam ============== This plugin allows restful resources to be automatically exposed with human readable urls based on another method on the resource. The URL parameter value that is computed will be unique within the model. If the model is using inheritance, it's recommended to define acts_as_url_param on the base class. Defines one public class methods on your model: MyResource.url_param_available?(candidate,id=nil) # => true # if the candidate value does not exist for the model Defines one public instance method on your model: my_resource.compute_url_param # => "unique-url-parameter-2" Contributors ============ "Chris Eppstein"<chris@eppsteins.net> "Joshua Bates"<joshuabates@gmail.com> Example ======= # use the url_param column as the model's url. It will be set and/or modified whenever the default method changes. # The default methods, in order of precedence, are: :name, :label, :title class MyResource < ActiveRecord::Base acts_as_url_param end # use the url_name column as the model's url. It will be set and/or modified whenever title changes class MyResource < ActiveRecord::Base acts_as_url_param :url_name, :from => :title end # use the url_param column as the model's url. It will be set and/or modified whenever title changes class MyResource < ActiveRecord::Base acts_as_url_param :from => :title end # use the url_param column as the model's url. It will be set and/or modified whenever the :on event occurs. # Allowed events are: :create, :save, :update. Default is :create so that your permalinks stay permanent. # May also be a Proc that accepts the model instance and returns true if url_param should change. class MyResource < ActiveRecord::Base acts_as_url_param :from => :title, :on => :create end # use the url_name column as the model's url. It will be set and/or modified whenever the :on event(s) occur. class MyResource < ActiveRecord::Base acts_as_url_param :url_name, :from => :title, :on => :create end # Passing a block allows you to approve candidate url parameters. # This enables definition of a url space across that spans several models. This is easiest if all # models are acts_as_url_param. class MyResource < ActiveRecord::Base acts_as_url_param :url_name, :from => :title do |candidate| MyResource.url_param_available?(candidate,self.id) && MyOtherResource.url_param_available?(candidate) end end Copyright (c) 2007 Chris Eppstein, released under the MIT license




