Skip to content

Instantly share code, notes, and snippets.

@SputterPuttRedux
Created February 18, 2015 22:51
Show Gist options
  • Save SputterPuttRedux/a336a0badb144ba5a896 to your computer and use it in GitHub Desktop.
Save SputterPuttRedux/a336a0badb144ba5a896 to your computer and use it in GitHub Desktop.
<div id="search-results">
<% if (@searched_stories + @searched_snippets).empty? %>
<br>
<h3> We couldn't find any content Containing "<%= params[:search] %>"</h3>
<% elsif !@searched_stories.empty? %>
<h3> Stories with "<%= params[:search] %> in the title: " </h3>
<% @searched_stories.each do |story| %>
<% display_string = story.title %>
<% x = params[:search].upcase %>
<% if display_string.include?(params[:search]) %>
<% display_string.sub!(params[:search], x ) %>
<br>
<li><%= link_to display_string, story_path(story) %></li>
<% end %>
<% end %>
<% end %>
<% if @searched_snippets.empty? %>
<br>
<h3>We couldn't find any Snippets containing "<%= params[:search] %>".</h3>
<% else %>
<h3> Snippets that contain"<%= params[:search] %>":</h3>
<% @searched_snippets.each do |snip| %>
<li><%= link_to snip.content, snippet_path(snip) %></li>
<% end %>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment