Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

burke/autolink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autolink

Autolink is a small set of monkeypatches to make linking to objects in deeply-namespaced url schemas completely painless. Say you have object @d, which is almost always referred to as /a/b/@d.b.id/c/@d.c.id/d/@d.id. This plugin lets you specify that default in @d’s model, then simply pass @d to rails’ link helpers. So ‘path_for @d` now returns ’/a/1/b/2/c/3/d/4’.

Installation

Autolink only works in Rails 2.3, and has only been tested on 2.3.8. Add it as a gem in config/environment.rb:

config.gem 'autolink'

Then add this to your ‘spec/spec_helper.rb’, under the line that requires ‘spec/rails’:

require 'autolink/rspec'

Now add this to any models that you want to autolink:

def default_lineage
  [:path, :to, :model, parent, self]
end

This default lineage works exactly like ActionController’s PolymorphicRouting lineage (since that’s what it is…).

I make no guarantees that this will work for you.

About

[abandoned] Automatically generate nested paths in Rails 2.3 according to your application's setup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages