Skip to content

Commit

Permalink
Update app/controllers/concerns/view_component/preview_actions.rb
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Lemuet <Spone@users.noreply.github.com>
  • Loading branch information
reedrolemodel and Spone committed Jun 22, 2023
1 parent d694ff3 commit 910acea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/concerns/view_component/preview_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def show_previews?
def find_preview
candidates = []
params[:path].to_s.scan(%r{/|$}) { candidates << Regexp.last_match.pre_match }
preview = candidates.sort_by { |candidate| -candidate.length }.detect { |candidate| ViewComponent::Preview.exists?(candidate) }
preview = candidates.sort_by(&:length).reverse_each.detect { |candidate| ViewComponent::Preview.exists?(candidate) }

if preview
@preview = ViewComponent::Preview.find(preview)
Expand Down

0 comments on commit 910acea

Please sign in to comment.