Q:

form search not working in rails app

In trying to implement search in my rails app, I can get my app to query on the search parameters entered, but the app does not display the contents of those that meet the query criteria.
Can you see why that is based on the code below?
index.html.erb:
<div id="search">
  <%= form_tag links_path, method: :get, authentication: :false, id: 'search-form' do %>
  <p>
    <%= text_field_tag :search %>
    <%= submit_tag "Search Party", name: :nil %>
  </p>
  <% end %>
</div>

<div id="link"><%= render @links %></div>

<%= will_paginate @links %>

links_controller.rb:
  def index
    if params[:search]
      Link.where("name LIKE ?", "%#{params[:search]}%")
      # Link.find(:all, :conditions => ["name LIKE ?", "%#{params[:search]}%"])
    else 
      Link.all
    end

      ordered_links = Link.order(cached_votes_score: :desc)
      @links = ordered_links.paginate(page: params[:page], per_page: 20)

      respond_to do |format| 
        format.js
        format.html
      end
  end

The URL processed:
http://localhost:3000/links?utf8=%E2%9C%93&search=97&nil=Search+Party

Rails Logs:
Started GET "/links?utf8=%E2%9C%93&search=97&nil=Search+Party" for ::1 at 2016-01-04 20:43:32 -0500
Processing by LinksController#index as HTML
  Parameters: {"utf8"=>"✓", "search"=>"97", "nil"=>"Search Party"}
  Link Load (0.3ms)  SELECT  "links".* FROM "links"  ORDER BY "links"."cached_votes_score" DESC LIMIT 20 OFFSET 0

If you were curious about what my links partial looked like, I included it.
_links.html.erb:
<div class="link row clearfix">
    <h2>
      <%= image_tag link.avatar.thumb %>
    </h2>
    <h2>
      <%= link_to link.title, link %><br>
    </h2>
    <p>
      <%= link_to link.url, link %><br>
    </p>

<!-- acts_as_votable for like_link -->
    <div class="btn-group">
        <%= link_to like_link_path(link), method: :put, class: "btn btn-default btn-sm" do %>
          <span class="glyphicon glyphicon-chevron-up"></span>
          Upvote
          <%= link.get_upvotes.size %>
        <% end %>
        <%= link_to dislike_link_path(link), method: :put, class: "btn btn-default btn-sm" do %>
          <span class="glyphicon glyphicon-chevron-down">
          Downvote
          <%= link.get_downvotes.size %>
        <% end %>
    </div>
</div>

SQL error after suggested edits from Yevgeniy:
ActionView::Template::Error (SQLite3::SQLException: no such column: name: SELECT  "links".* FROM "links" WHERE (name LIKE '%98%')  ORDER BY "links"."cached_votes_score" DESC LIMIT 20 OFFSET 0):
     7:   <% end %>
     8: </div>
     9: 
    10: <div id="link"><%= render @links %></div>
    11: 
    12: <%= will_paginate @links %>
  app/views/links/index.html.erb:10:in `_app_views_links_index_html_erb__2780104518371497637_70253166090580'
  app/controllers/links_controller.rb:7:in `index'

It seems like the controller is not picking up on the searched item and is moving onto the 'else' part of the if statement, although I have content that matches 98.

A:

The controller is picking up the criteria, its just that after the if block you are doing:
  ordered_links = Link.order(cached_votes_score: :desc)
  @links = ordered_links.paginate(page: params[:page], per_page: 20)

Which selects everything from link table and just orders it.  Anything you done prior to that has no effect since its not assigned to a variable.
Try this in your links_controller.rb:
  def index
      @links = ordered_links.paginate(page: params[:page], per_page: 20)

      respond_to do |format| 
        format.js
        format.html
      end
  end

  private

    def search_criteria_present?
       !params[:search].nil?
    end

    def searched_links
      if search_criteria_present?
        Link.where("name LIKE ?", "%#{params[:search]}%")
      else
        Link
      end
    end

    def ordered_links
      searched_links.order(cached_votes_score: :desc)
    end

