Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Fixed back button functionality
Browse files Browse the repository at this point in the history
Addresses #254

We now store the previous URL if coming from a topic page and use that for the back button link.
  • Loading branch information
jdudley1123 committed Apr 8, 2020
1 parent 88639b7 commit 124a5db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ def show
end

@offer = Offer.find(params[:id])

previous_url = URI(request.referer || '').path
if previous_url.include? "topic"
session[:previous_url] = previous_url
end
@back_url = session[:previous_url]
end
end
2 changes: 1 addition & 1 deletion app/views/offers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= render partial: 'projects/subnav' %>

<div class="max-w-3xl mx-auto px-4 my-8">
<p class="mb-6"><%= link_to '‹ Back', :back, class: 'underline' %></p>
<p class="mb-6"><%= link_to '‹ Back', @back_url, class: 'underline' %></p>
<%= render partial: 'layouts/notices' %>

<div class="card">
Expand Down

0 comments on commit 124a5db

Please sign in to comment.