Skip to content
Newer
Older
100644 151 lines (100 sloc) 5.16 KB
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
1 # FriendlyId
2
5d94960 @andyw8 Fix broken TravisCI image
andyw8 authored Dec 6, 2012
3 [![Build Status](https://travis-ci.org/norman/friendly_id.png)](https://travis-ci.org/norman/friendly_id)
ee73161 @norman Added Travis status image
authored Aug 14, 2011
4
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
5 FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
6 Ruby on Rails. It allows you to create pretty URLs and work with human-friendly
a4128af @norman Continued work on docs
authored Aug 6, 2011
7 strings as if they were numeric ids for Active Record models.
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
8
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
9 Using FriendlyId, it's easy to make your application use URLs like:
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
10
11 http://example.com/states/washington
12
13 instead of:
14
15 http://example.com/states/4323454
16
f68be81 @norman Added link to docs
authored Aug 6, 2011
17
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
18 ## FriendlyId Features
19
20 FriendlyId offers many advanced features, including: slug history and
c7f695a @norman Doc tweaks
authored Feb 29, 2012
21 versioning, i18n, Globalize support, scoped slugs, reserved words, and custom
22 slug generators.
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
23
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
24 FriendlyId is compatible with Active Record **3.0** and higher.
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
25
004d623 @norman Docs tweaks
authored Aug 15, 2011
26 ## Version 4.x
27
f5f28ca @norman Update docs, bump version
authored Aug 15, 2011
28 FriendlyId 4.x introduces many changes incompatible with 3.x. If you're
29 upgrading, please [read the
9b00a11 @norman Updated doc links
authored Aug 27, 2013
30 docs](http://norman.github.io/friendly_id/4.0/file.WhatsNew.html) to see what's
f5f28ca @norman Update docs, bump version
authored Aug 15, 2011
31 new.
004d623 @norman Docs tweaks
authored Aug 15, 2011
32
aa1fe01 @norman Updated README
authored Aug 17, 2011
33 ## Docs
34
9b00a11 @norman Updated doc links
authored Aug 27, 2013
35 The docs for this version can always be found
36 [here](http://norman.github.io/friendly_id/4.0/).
aa1fe01 @norman Updated README
authored Aug 17, 2011
37
86b0c09 @norman Added generated guide from RDoc
authored Dec 19, 2011
38 The best place to start is with the
9b00a11 @norman Updated doc links
authored Aug 27, 2013
39 [Guide](http://norman.github.io/friendly_id/4.0/file.Guide.html),
86b0c09 @norman Added generated guide from RDoc
authored Dec 19, 2011
40 which compiles the top-level RDocs into one outlined document.
aa1fe01 @norman Updated README
authored Aug 17, 2011
41
b364a55 @norman Added Railscast link.
authored Jan 10, 2012
42 You might also want to watch Ryan Bates's [Railscast on FriendlyId](http://railscasts.com/episodes/314-pretty-urls-with-friendlyid).
43
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
44 ## Rails Quickstart
45
46 gem install friendly_id
47
48 rails new my_app
49
50 cd my_app
51
9b00a11 @norman Updated doc links
authored Aug 27, 2013
52 gem "friendly_id", "~> 4.0.10" # Note: You MUST use 4.0.9 or greater for Rails 3.2.10+
204c477 @norman Bump version, update README
authored Jul 30, 2011
53
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
54 rails generate scaffold user name:string slug:string
55
56 # edit db/migrate/*_create_users.rb
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
57 add_index :users, :slug, unique: true
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
58
59 rake db:migrate
60
61 # edit app/models/user.rb
62 class User < ActiveRecord::Base
70c8884 @norman has_friendly_id => friendly_id, and accept "use" arg to load modules
authored Jul 17, 2011
63 extend FriendlyId
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
64 friendly_id :name, use: :slugged
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
65 end
66
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
67 User.create! name: "Joe Schmoe"
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
68
69 rails server
70
71 GET http://localhost:3000/users/joe-schmoe
72
aa1fe01 @norman Updated README
authored Aug 17, 2011
73 # If you're adding FriendlyId to an existing app and need
74 # to generate slugs for existing users, do this from the
75 # console, runner, or add a Rake task:
1be839f @manuelmeurer Use `find_each` instead of `all`, since there might be a lot of users…
manuelmeurer authored Oct 7, 2011
76 User.find_each(&:save)
f68be81 @norman Added link to docs
authored Aug 6, 2011
77
a4128af @norman Continued work on docs
authored Aug 6, 2011
78
ce7eb3c @norman Worked on documentation.
authored Aug 6, 2011
79 ## Benchmarks
80
81 The latest benchmarks for FriendlyId are maintained
aa40f56 @norman Improve peformance of finds using old friendly_id
authored Sep 3, 2011
82 [here](http://bit.ly/friendly-id-benchmarks).
ce7eb3c @norman Worked on documentation.
authored Aug 6, 2011
83
84
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
85 ## Bugs
86
bda2b36 @norman Doc tweaks
authored Jul 17, 2011
87 Please report them on the [Github issue
88 tracker](http://github.com/norman/friendly_id/issues) for this project.
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
89
90 If you have a bug to report, please include the following information:
91
92 * **Version information for FriendlyId, Rails and Ruby.**
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
93 * Full stack trace and error message (if you have them).
aa1fe01 @norman Updated README
authored Aug 17, 2011
94 * Any snippets of relevant model, view or controller code that shows how you
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
95 are using FriendlyId.
96
97 If you are able to, it helps even more if you can fork FriendlyId on Github,
98 and add a test that reproduces the error you are experiencing.
99
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
100 For more info on how to report bugs, please see [this
101 article](http://yourbugreportneedsmore.info/).
102
aa1fe01 @norman Updated README
authored Aug 17, 2011
103 ## Thanks and Credits
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
104
bda2b36 @norman Doc tweaks
authored Jul 17, 2011
105 FriendlyId was originally created by Norman Clarke and Adrian Mugnolo, with
d2f9c91 @qnm Fix tiny typo in readme
qnm authored Dec 7, 2012
106 significant help early in its life by Emilio Tagua. I'm deeply grateful for the
bda2b36 @norman Doc tweaks
authored Jul 17, 2011
107 generous contributions over the years from [many
8777f06 @norman Initial commit to 4.0.0
authored Jun 25, 2011
108 volunteers](https://github.com/norman/friendly_id/contributors).
109
d261d19 @norman Added note on Slugged
authored Aug 15, 2011
110 Part of the inspiration to rework FriendlyId came from Darcy Laycock's library
111 [Slugged](https://github.com/Sutto/slugged), which he was inspired to create
112 because of frustrations he experienced while using FriendlyId 3.x. Seeing a
113 smart programmer become frustrated with my code was enough of a kick in the
e4045ab @norman Small doc tweaks.
authored Dec 28, 2011
114 butt to make me want to significantly improve this library.
d261d19 @norman Added note on Slugged
authored Aug 15, 2011
115
116 Many thanks to him for providing valid, real criticism while still being a cool
117 about it. I definitely recommend you check out his library if for some reason
118 FriendlyId doesn't do it for you.
119
aa1fe01 @norman Updated README
authored Aug 17, 2011
120 Thanks also to Loren Segal and Nick Plante for YARD and the
121 [rubydoc.info](http://rubydoc.info/) website which FriendlyId uses for
122 documentation.
123
ee73161 @norman Added Travis status image
authored Aug 15, 2011
124 Lastly, FriendlyId uses [Travis](http://travis-ci.org/) for continuous
125 integration. It's an excellent, free service created by a whole bunch of [good
126 people](https://github.com/travis-ci) - if you're not already using it, you
127 should be!
128
aa1fe01 @norman Updated README
authored Aug 17, 2011
129 ## License
130
258baba @norman Add @parndt to authors
authored Aug 1, 2012
131 Copyright (c) 2008-2012 Norman Clarke and contributors, released under the MIT
132 license.
aa1fe01 @norman Updated README
authored Aug 17, 2011
133
134 Permission is hereby granted, free of charge, to any person obtaining a copy of
135 this software and associated documentation files (the "Software"), to deal in
136 the Software without restriction, including without limitation the rights to
137 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
138 of the Software, and to permit persons to whom the Software is furnished to do
139 so, subject to the following conditions:
140
141 The above copyright notice and this permission notice shall be included in all
142 copies or substantial portions of the Software.
143
144 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
145 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
146 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
147 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
148 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
149 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
150 SOFTWARE.
Something went wrong with that request. Please try again.