0
@@ -15,8 +15,16 @@ which will populate the <tt>url</tt> attribute on the object with the converted
0
<tt>:scope</tt>:: The name of model attribute to scope unique urls to. There is no default here.
0
<tt>:sync_url</tt>:: If set to true, the url field will be updated when changes are made to the
0
attribute it is based on. Default is false.
0
+In order to use the generated url attribute, you will probably want to override <tt>to_param</tt> like so, in your Model:
0
-<b>Note:</b> Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inconsistent across platforms and doesn't provide great transliteration as is) but instead uses a transliteration scheme (see the code for Unidecoder) which produces much better results for Unicode characters. It also mixes in some custom helpers to translate common characters into a more URI-friendly format rather than just dump them completely. Examples:
0
+ url # or whatever you set :url_attribute to
0
+Routing called via named routes like <tt>foo_path(@foo)</tt> will automatically use the url. In your controllers you will need to call <tt>Foo.find_by_url(params[:id])</tt> instead of the regular find. Don't look for <tt>params[:url]</tt> unless you set it explicitly in the routing, <tt>to_param</tt> will generate <tt>params[:id]</tt>.
0
+Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inconsistent across platforms and doesn't provide great transliteration as is) but instead uses a transliteration scheme (see the code for Unidecoder) which produces much better results for Unicode characters. It also mixes in some custom helpers to translate common characters into a more URI-friendly format rather than just dump them completely. Examples:
0
"simple English".to_url => "simple-english"
0
@@ -61,6 +69,6 @@ A collection of extensions on Ruby's String class. Please see the documentation
0
== Thanks & Acknowledgements
0
-If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's permalink_fu[http://svn.techno-weenie.net/projects/plugins/permalink_fu/] plugin. Unidecoder is a Ruby port of Sean Burke's Text::Unidecode[http://interglacial.com/~sburke/tpj/as_html/tpj22.html] module for Perl. And, finally, the bulk of
String#strip_html in StringExtensions was stolen from Tobias Lütke's Regex in Typo[http://typosphere.org/].
0
+If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's permalink_fu[http://svn.techno-weenie.net/projects/plugins/permalink_fu/] plugin. Unidecoder is a Ruby port of Sean Burke's Text::Unidecode[http://interglacial.com/~sburke/tpj/as_html/tpj22.html] module for Perl. And, finally, the bulk of
strip_html_tags[link:classes/LuckySneaks/StringExtensions.html#M000005] in StringExtensions was stolen from Tobias Lütke's Regex in Typo[http://typosphere.org/].
0
copyright (c) 2008 Lucky Sneaks, released under the MIT license
Comments
No one has commented yet.