Skip to content

Commit 7fdb8f3

Browse files
committed
Merge pull request #235 from MGerrior/MGerrior-patch-1
Improve clarity of installation instructions
2 parents 0c04b0c + d8e975f commit 7fdb8f3

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

README.rdoc

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,51 @@ Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord
1010

1111
To apply Ancestry to any ActiveRecord model, follow these simple steps:
1212

13-
1. Install
14-
- <b>Rails 2</b>
15-
- See 1-3-stable branch
16-
- <b>Rails 3</b>
17-
- Add to Gemfile: <b>gem 'ancestry'</b>
18-
- Install required gems: <b>bundle install</b>
19-
20-
2. Add ancestry column to your table
21-
- Create migration: <b>rails g migration add_ancestry_to_[table] ancestry:string</b>
22-
- Add index to migration: <b>add_index [table], :ancestry</b> (UP) / <b>remove_index [table], :ancestry</b> (DOWN)
23-
- Migrate your database: <b>rake db:migrate</b>
24-
25-
3. Add ancestry to your model
26-
- Add to app/models/[model].rb: <b>has_ancestry</b>
13+
== Install
14+
=== Rails 2
15+
- See 1-3-stable branch
16+
=== Rails 3
17+
- Add to Gemfile:
18+
# Gemfile
19+
20+
gem 'ancestry'
21+
- Install required gems:
22+
$ bundle install
23+
24+
== Add ancestry column to your table
25+
- Create migration:
26+
$ rails g migration add_ancestry_to_[table] ancestry:string
27+
- Add index to migration:
28+
# db/migrate/[date]_add_ancestry_to_[table].rb
29+
30+
class AddAncestryTo[Table] < ActiveRecord::Migration
31+
# Rails 4 Syntax
32+
def change
33+
add_column [table], :ancestry, :string
34+
add_index [table], :ancestry
35+
end
36+
37+
# Rails 3 Syntax
38+
def up
39+
add_column [table], :ancestry, :string
40+
add_index [table], :ancestry
41+
end
42+
43+
def down
44+
remove_column [table], :ancestry
45+
remove_index [table], :ancestry
46+
end
47+
48+
- Migrate your database:
49+
$ rake db:migrate
50+
51+
== Add ancestry to your model
52+
- Add to app/models/[model].rb:
53+
# app/models/[model.rb]
54+
55+
class [Model] < ActiveRecord::Base
56+
has_ancestry
57+
end
2758

2859
Your model is now a tree!
2960

0 commit comments

Comments
 (0)