Skip to content

About

Slug generation for ActiveRecord models

Resources

Stars

2 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

Generate slugs for your models

…then add the following to a model you’d like to slug:

class MyClass < ActiveRecord::Base
  include Slugify
  slugify :title
end

Throw it in vendor/plugins (with script/plugin install, braid, submodules, or whatever your preferred installation method), and add the following to a model you’d like to slug:

class MyClass < ActiveRecord::Base
  include Slugify
  slugify :title
end

If you are using slugify in multiple models, you may want to mix it into ActiveRecord::Base:

ActiveRecord::Base.instance_eval do
  include Slugify
end

class MyClass < ActiveRecord::Base
  slugify :title
end
class Page < ActiveRecord::Base
  include Slugify

  validates_presence_of :title

  slugify :title
end

Page.create(:title => "Foo")
# => #<Page id: 1, title: "Foo", slug: "foo">

Page.create(:title => "Foo")
# => #<Page id: 1, title: "Foo", slug: "foo-0">
slugify :my_column, :slug_column => :bar
slugify :slug_column, :scope => :col_one
slugify :slug_column, :scope => [:col_one, :col_two]
slugify :my_column, :when => lambda { |my_record| my_record.published? }
kule - STI Issues [Github Issue #1]

About

Slug generation for ActiveRecord models

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages