Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 96 lines (57 sloc) 2.67 kB
8777f06 @norman Initial commit to 4.0.0
authored
1 # FriendlyId
2
3 FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for
a4128af @norman Continued work on docs
authored
4 Ruby on Rails. It allows you to create pretty URL's and work with human-friendly
5 strings as if they were numeric ids for Active Record models.
8777f06 @norman Initial commit to 4.0.0
authored
6
7 Using FriendlyId, it's easy to make your application use URL's like:
8
9 http://example.com/states/washington
10
11 instead of:
12
13 http://example.com/states/4323454
14
f68be81 @norman Added link to docs
authored
15
8777f06 @norman Initial commit to 4.0.0
authored
16 ## FriendlyId Features
17
18 FriendlyId offers many advanced features, including: slug history and
a4128af @norman Continued work on docs
authored
19 versioning, scoped slugs, reserved words, and custom slug generators.
8777f06 @norman Initial commit to 4.0.0
authored
20
21 FriendlyId is compatible with Active Record **3.0** and **3.1**.
22
23 ## Rails Quickstart
24
25 gem install friendly_id
26
27 rails new my_app
28
29 cd my_app
30
204c477 @norman Bump version, update README
authored
31 # Add to Gemfile - this will change once version 4 is no longer
32 # in beta, but for now do this:
33 gem "friendly_id4", "4.0.0.beta4", :require => "friendly_id"
34
8777f06 @norman Initial commit to 4.0.0
authored
35
36 rails generate scaffold user name:string slug:string
37
38 # edit db/migrate/*_create_users.rb
39 add_index :users, :slug, :unique => true
40
41 rake db:migrate
42
43 # edit app/models/user.rb
44 class User < ActiveRecord::Base
70c8884 @norman has_friendly_id => friendly_id, and accept "use" arg to load modules
authored
45 extend FriendlyId
46 friendly_id :name, :use => :slugged
8777f06 @norman Initial commit to 4.0.0
authored
47 end
48
49 User.create! :name => "Joe Schmoe"
50
51 rails server
52
53 GET http://localhost:3000/users/joe-schmoe
54
f68be81 @norman Added link to docs
authored
55 ## Docs
56
57 The current docs can be found
58 [here](http://rdoc.info/github/norman/friendly_id/a4128af31d85ee29ad8f/frames).
a4128af @norman Continued work on docs
authored
59
f68be81 @norman Added link to docs
authored
60 ## Future Compatibility
a4128af @norman Continued work on docs
authored
61
62 FriendlyId will always remain compatible with the current release of Rails, and
63 at least one stable release behind. That means that support for 3.0.x will not be
64 dropped until a stable release of 3.2 is out, or possibly longer.
65
66
ce7eb3c @norman Worked on documentation.
authored
67 ## Benchmarks
68
69 The latest benchmarks for FriendlyId are maintained
70 [here](https://gist.github.com/1129745).
71
72
8777f06 @norman Initial commit to 4.0.0
authored
73 ## Bugs
74
bda2b36 @norman Doc tweaks
authored
75 Please report them on the [Github issue
76 tracker](http://github.com/norman/friendly_id/issues) for this project.
8777f06 @norman Initial commit to 4.0.0
authored
77
78 If you have a bug to report, please include the following information:
79
80 * **Version information for FriendlyId, Rails and Ruby.**
81 * Stack trace and error message.
bda2b36 @norman Doc tweaks
authored
82 * Any snippets of relevant model, view or controller code that shows how you
8777f06 @norman Initial commit to 4.0.0
authored
83 are using FriendlyId.
84
85 If you are able to, it helps even more if you can fork FriendlyId on Github,
86 and add a test that reproduces the error you are experiencing.
87
88 ## Credits
89
bda2b36 @norman Doc tweaks
authored
90 FriendlyId was originally created by Norman Clarke and Adrian Mugnolo, with
91 significant help early in its life by Emilio Tagua. I'm deeply gratful for the
92 generous contributions over the years from [many
8777f06 @norman Initial commit to 4.0.0
authored
93 volunteers](https://github.com/norman/friendly_id/contributors).
94
95 Copyright (c) 2008-2011 Norman Clarke, released under the MIT license.
Something went wrong with that request. Please try again.