Simple search only searching last word of record
- by bennett_an
I set up a simple search as instructed in part of railscast #240.
in controller
@reports = Report.search(params[:search]).order('created_at DESC').paginate(:page => params[:page], :per_page => 5)
in model
def self.search(search)
if search
where('apparatus LIKE ?', "%#{search}")
else
scoped
end
end
in view
<%= form_tag reports_path, :method => :get do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
</p>
<% end %>
it all works... but...
I have a few records for example, one with "another time test" and another with "last test of time"
if i search "test" the first comes up but the second doesn't, and if i search "time" the second comes up but not the first. It is only seeing the last word of the record.
what gives?