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 (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Fri Aug 22 05:14:57 -0700 2008 | |
| |
README | Fri Aug 22 05:56:09 -0700 2008 | |
| |
Rakefile | Fri Aug 22 05:14:57 -0700 2008 | |
| |
init.rb | Fri Aug 22 05:14:57 -0700 2008 | |
| |
install.rb | ||
| |
lib/ | Fri Jun 26 09:08:27 -0700 2009 | |
| |
tasks/ | ||
| |
test/ | Fri Aug 22 05:14:57 -0700 2008 | |
| |
uninstall.rb |
README
ActsAsUriNamed
==============
This plugin does the wrong thing we all do. It makes your model uri-name
field work as the primary key when you need it. Say for articles, blog
entries and so ones.
Example
=======
class Article < ActiveRecod::Base
acts_as_uri_named
end
@article = Article.new :uri_name => 'bla-bla-bla'
article_path @article -> '/articles/bla-bla-bla'
Article.find('bla-bla-bla') will return the @article.
The original functionality is still available
Article.find(@article.id) will return the @article
Nested Urls Handling
====================
If you have a nested units, with your model you can search by
the full path like
@article1 = Article.create :uri_name => 'bla'
@article2 = Article.create :uri_name => 'asdf', :parent => @article1
Article.find_by_full_uri_name('/bla/asdf') will return @article2
And you have a method to compile the full urls
@article1.full_uri_name -> '/bla'
@article2.full_uri_name -> '/bla/asdf'
You can specify the scope field for your nested units, which is
'parent_id' by default.
class Node < ActiveRecord::Base
acts_as_uri_named :scope => :node_id
belongs_to :node
has_many :nodes
end
Validation Skipping
===================
You can skip the plugin's builtin validators if you have some own
validations in your model which conflicts or duplicates the plugins
validations.
class User < ActiveRecord::Base
acts_as_uri_named :uri_name_field => :login, :validate => false
validates_presence_of :login ....
.....
end
--
Copyright (c) 2008 [Nikolay V. Nemshilov aka St.],
released under the MIT license









