I am trying to create a form where I can retrieve the information. So far I have implemented a model and a controller with an action query.
Here's the form:
<%= form_tag "/search", :method => "get" do %>
<%= text_field_tag :query, params[:query] %>
<%= submit_tag "Search", :name => nil %>
<% end %>
My controller has:
def query @results = Search.search(params[:query] ) end
And in my models I have:
def self.search(search)
if search
Customer.find(:all, :conditions => ['first LIKE ?', "%#{search}%"])
else
Customer.find(:all)
end
end
But it give me the following error:
ActiveRecord::StatementInvalid in SearchesController#query
SQLite3::SQLException: no such column: first: SELECT "customers".* FROM "customers" WHERE (first LIKE '%test%')
Why does my code produce this error?
That's probably because you don't have a first column in customers table on the DB.
Did you mean maybe first_name ?