Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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