Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
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