As find with conditions is being deleted from Rails 3.2. I have re-
factored my search code using the new syntax. In any case my find with
conditions was throwing errors. (find(:all, :conditions => ['section
LIKE ?', "%#{search_item}%"]))
Can anyone help in finding out why my instance variable @homepages is
returning with nothing from the search.

In my controller I have:-
    @homepages = Homepage.search(params[:search])

In my model I have:-
    class Homepage < ActiveRecord::Base
  def self.search(search_item)
    if search_item
     self.where('section <= ?', "%#{search_item}%")
    else
      self.all
    end
  end
end

In my index.js.erb I have:-
    $("testsearch").update("<%= escape_javascript(render(@homepages))
%>");

My terminal log shows the search values are being passed correctly,
but nothing is being rendered:-
    Started GET "/homepages?utf8=%E2%9C%93&search=Gar" for 127.0.0.1
at 2010-10-29 01:27:42 +0100
  Processing by HomepagesController#index as JS
  Parameters: {"utf8"=>"✓", "search"=>"Gar"}
  Homepage Load (0.4ms)  SELECT "homepages".* FROM "homepages" WHERE
(section <= '%Gar%')
Rendered collection (0.0ms)
Rendered homepages/index.js.erb (1.9ms)
Completed 200 OK in 9036ms (Views: 9.7ms | ActiveRecord: 0.4ms)

It should find at least one record. If I make the if the same as the
else it renders all correctly. So why am I not getting any records
returned with @homepages.
Thanks in advance. Don

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to