Hello all, I'm in my third month of Ruby on Rails. I think it's coming along fairly well. My current issue is this.
I'm do a search based on string data some of which is very long. So I'm doing a similar match using "amatch" gem. When I have a 50% or greater match I store the id to an array. How can I do a find looping thru the array then send the query results to a partial. I have the following... - projects_controller - def search # get list of search parameters from id sent. list = params[:id] # split by comma list = list.split(',') # assign each id_search_string = list[0] title_search_string = list[1] # create new instance of Levenshtein using 'amatch' m = Levenshtein.new(title_search_string) # retrieve all titles from projects @title = Project.find(:all, :select => 'DISTINCT id, title') # create projects array projects = Array.new # loop thru all titles @title.each do |project| # if title search string more than 50% similar to the project title. if m.similar(project.title) >= 0.5 puts "ID:"+project.id.to_s + ", " + m.similar(project.title).to_s # push to array projects.push(project.id) end end # Next, we need to access all matching ids then query project table for ids. # loop thru array # HERE'S WHERE I'M LOST projects.each do |m| m.id end #QUERY USING SEARCHLOGIC, IF EASIER I COULD USE JUST "FIND" projects = Project.id_like(id).paginate(:page => params[:page], :per_page => 20) #RENDER PARTIAL render :partial => 'projects/results', :locals => {:projects => projects} end Thank you for any help on this. JohnM -- Posted via http://www.ruby-forum.com/.
-- 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.