I want to create a search box (form) that when submitted will pass the search_word into the query string.
<%= link_to articles_path(title: "search_word") %>
class Article < Active Record::Base
scope :title, -> (title) { where("title ILIKE ?", "%#{title}%")}
end
class ArticlesController < ApplicationController
def index
@articles = Article.all
@articles = @articles.title(params[:title]) if params[:title].present?
end
end
This will allow the User to use the search box to search the articles by title.