Skip to content

Commit d6bcca2

Browse files
p8rafaelfranca
authored andcommitted
Add path to version select in guides
When selecting another version of the guide we can append the path to the version URL. This makes sure someone stays on "Active Record Basics" guide when switching versions.
1 parent f8eba0c commit d6bcca2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

guides/rails_guides/generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def generate_guide(guide, output_file)
188188
[@source_dir],
189189
edge: @edge,
190190
version: @version,
191+
path: output_file,
191192
epub: "epub/#{epub_filename}",
192193
language: @language,
193194
direction: @direction,

guides/source/layout.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<select id="version-switcher-select" class="guides-version">
7171
<option value="https://edgeguides.rubyonrails.org/"<%= " selected" if @edge %>>Edge</option>
7272
<% %w[8.0 7.2 7.1 7.0 6.1 6.0 5.2 5.1 5.0 4.2 4.1 4.0 3.2 3.1 3.0 2.3].each do |version| %>
73-
<option value="https://guides.rubyonrails.org/v<%= version %>/"<%= " selected" if @version&.start_with?("v#{version}") %>><%= version %></option>
73+
<option value="https://guides.rubyonrails.org/v<%= version %>/<%= @path %>"<%= " selected" if @version&.start_with?("v#{version}") %>><%= version %></option>
7474
<% end %>
7575
</select>
7676
</span>

0 commit comments

Comments
 (0)