From 1f19ebfd6610c01036b602aeeb37fb57bc3d4e6a Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Mon, 12 Sep 2022 10:51:34 +0200 Subject: [PATCH 1/2] copyright transfer to gut.org --- LICENSE.txt | 2 +- README.rdoc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 998b109..9e78ba4 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2012 Daniel Hahn +Copyright (c) 2012 Daniel Hahn, 2022 gut.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.rdoc b/README.rdoc index f60390d..e8da435 100644 --- a/README.rdoc +++ b/README.rdoc @@ -19,6 +19,5 @@ So we came up with this little thing, which was a drop-in replacement for us, an == Copyright -Copyright (c) 2012 Daniel Hahn. See LICENSE.txt for +Copyright (c) 2012 Daniel Hahn, 2022 [gut.org](https://gut.org). See [LICENSE.txt](LICENSE.txt) for further details. - From a66e71dba052dead036d562b372d59ea47881392 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Mon, 12 Sep 2022 11:05:33 +0200 Subject: [PATCH 2/2] add super basic documentation --- README.rdoc | 8 ++++++++ lib/sane_permalinks/class_methods.rb | 3 +++ 2 files changed, 11 insertions(+) diff --git a/README.rdoc b/README.rdoc index e8da435..069f49c 100644 --- a/README.rdoc +++ b/README.rdoc @@ -7,6 +7,14 @@ This is mostly itchy-scratchy-ware. We didn't really want the self-proclaimed "s So we came up with this little thing, which was a drop-in replacement for us, and does exactly what we need. If you like it take a go, otherwise check out one of the established alternatives or roll your own ;-() +== Usage + +Call `SanePermalinks.init` to make `ActiveRecord::Base` extend and include the relevant modules and alias `to_param`. + +Let `make_permalink with: :name` define by which `find_by` (here: `find_by_name`) the new `find_by_param` should find the record in your model class. + +`find_by_param` can throw a `SanePermalinks::WrongPermalink` error when the "slugs" do not exactly fit. + == Contributing to sane_permalinks * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet diff --git a/lib/sane_permalinks/class_methods.rb b/lib/sane_permalinks/class_methods.rb index 88ad1ea..ff710ef 100644 --- a/lib/sane_permalinks/class_methods.rb +++ b/lib/sane_permalinks/class_methods.rb @@ -6,6 +6,9 @@ def permalink_options @permalink_options || {} end + # supported options: + # - with (str/symbol): define the xyz in `find_by_xyz` from find_by_param + # - prepend_id (bool): if permalinks shall look like 1-the_name_or_title def make_permalink(options) @permalink_options = options end