I am trying to implement a simple search function which triggers a number of argument error. Here My views
<%= form_tag(clients_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search Clients" %>
<%= submit_tag "Search", :name => nil %>
<% end %>
The method in my controller
def index
if current_user.admin?
if params[:search]
@clients = Client.search(params[:search], load:true).result
else
@clients = Client.all.paginate(:per_page => 3, :page => params[:page])
end
else
@clients = current_user.clients
end
end
My model
def self.search(query)
where("name like ?","%#{query}%")
end
I get the error message "wrong number of arguments (2 for 1)". I don't see what is the other argument passed to the model. A fresh pair of eyes will help. Thanks.
Your
searchmethod allow only one argument:But you trying to use it with 2: