`
wtb
  • 浏览: 103545 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

让url更人性化_acts_as_slugable

阅读更多

== 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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics