aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guides/rails_guides/markdown/renderer.rb23
-rw-r--r--guides/source/5_0_release_notes.md2
2 files changed, 24 insertions, 1 deletions
diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb
index deab741023..2fc2c5d9cb 100644
--- a/guides/rails_guides/markdown/renderer.rb
+++ b/guides/rails_guides/markdown/renderer.rb
@@ -15,6 +15,16 @@ module RailsGuides
HTML
end
+ def link(url, title, content)
+ if url.start_with?('http://api.rubyonrails.org')
+ %(<a href="#{api_link(url)}">#{content}</a>)
+ elsif title
+ %(<a href="#{url}" title="#{title}">#{content}</a>)
+ else
+ %(<a href="#{url}">#{content}</a>)
+ end
+ end
+
def header(text, header_level)
# Always increase the heading level by 1, so we can use h1, h2 heading in the document
header_level += 1
@@ -79,6 +89,19 @@ HTML
%(<div class="#{css_class}"><p>#{$2.strip}</p></div>)
end
end
+
+ def version
+ ENV['RAILS_VERSION']
+ end
+
+ def api_link(url)
+ if version && !url.match(/v\d\.\d\.\d/)
+ url.insert(url.index('.org')+4, "/#{version}")
+ url.sub('http://edgeapi', 'http://api') if url.include?('edgeapi')
+ end
+
+ url
+ end
end
end
end
diff --git a/guides/source/5_0_release_notes.md b/guides/source/5_0_release_notes.md
index 24fb0ca6e1..e1b3b0a42e 100644
--- a/guides/source/5_0_release_notes.md
+++ b/guides/source/5_0_release_notes.md
@@ -150,7 +150,7 @@ The type of an attribute is given the opportunity to change how dirty
tracking is performed.
See its
-[documentation](http://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html)
+[documentation](http://api.rubyonrails.org/v5.0.1/classes/ActiveRecord/Attributes/ClassMethods.html)
for a detailed write up.