== Installation
<tt>./script/plugin install http://code.dunae.ca/acts_as_slugable</tt>
== Usage examples
In your target table, add a column to hold the URL slug.
=== With scope
class Page < ActiveRecord::Base
acts_as_slugable :source_column => :title, :target_column => :url_slug, :scope => :parent
end
=== Without scope
class Post < ActiveRecord::Base
acts_as_slugable :source_column => :title, :target_column => :url_slug
end
=== A sample link
link_to @page.title, :action => 'show', :url_slug => @page.url_slug
让url更人性化_acts_as_slugable
最新推荐文章于 2024-11-15 13:13:23 发布
本文介绍了一个名为'acts_as_slugable'的插件的安装及使用方法。该插件能够帮助开发者为 ActiveRecord 模型生成 URL 友好的 slug 字段。文章通过示例展示了如何在不同场景下配置此插件,包括带命名空间的配置和不带命名空间的配置。
2568

被折叠的 条评论
为什么被折叠?



