As per the often cited Justin Weiss article on scopes. The goal is that the titles of Articles can be searched by keyword, so that the query string ?title=kayne populates @articles.title with articles with kayne in the title.
class Article < Active Record::Base
.
.
scope :title, -> (title) { where("title like ?", "%#{title}%")}
end
class ArticlesController < ApplicationController
def index
@articles = Article.all
@articles = @articles.title if params[:title].present?
end
end
Heroku Log
Parameters: {"title"=>"kayne"}
: Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
: ArgumentError (wrong number of arguments (0 for 1)):