So this is very strange. I followed this railscast http://railscasts.com/episodes/37-simple-search-form and after I implemented everything that looked like this
index.html.erb
<%= form_tag findjobs_path, :method => 'get' do %> <p> <%= text_field_tag :search %> <%= submit_tag "search" %> </p> <% end %>
listings_controller.rb
def index @listings = Listing.all @listings = Listing.paginate(:page => params[:page], :per_page => 10) @user = User.find_by_name(params[:name]) @listing = Listing.find_by_id(params[:id]) @categories = Category.all @listings = Listing.search(params[:search]) end end
listing.rb
def self.search(search) if search find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) else find(:all) end end
I get the following error: Could not find Listing with 'id' = all I understand that the search methods look immediately for the identifier. However, I do not know how I need to configure it so that it looks through all my lists. find_by_all, of course, does not work.
I hope someone can help
Thank you
source share