Ruby on Rails Monday, December 7, 2015

when the search gets submitted it only returns results for records that had the searched value in publicists

from my model:
 def self.search(search)
  where("headline LIKE ?", "%#{search}%")
  where("storyline LIKE ?", "%#{search}%")
  where("publicist LIKE ?", "%#{search}%")
 end

from my  controller:
def index
  if params[:search]
    @press_releases = PressRelease.search(params[:search]).order("dateline DESC")
  else
    @press_releases = PressRelease.order("dateline DESC")
  end
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/95418b64-fd59-43db-b123-6812c8009b54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment