James, Indeed this was working, I was messing it up ... thanks for the help
thanks also for the tip regarding :with_all, exactly what I needed. I am now struggling with one last issue. I am trying to index a difference between 2 fields (possible?) I want to be able this way to search by books that has sold x out of y available copies. something lilke: has books_total - books_sold, :as => books_left Is this even possible or should i just make a new column in my table containing this value? It seems I am in deep water as the index builder is throwing errors at me.. both columns are integer values though and I can add them seperatly.. hope anyone can help -- Peter Tellgren On Wed, Apr 15, 2009 at 12:46 PM, James Healy <[email protected]> wrote: > Peter Tellgren wrote: > > here is what I have so far not working... (quite new to rails) > > index.html.erb > > <% for tag in Tag.find(:all, :order => "name asc") %> > > <%= check_box_tag 'tag_ids[]', tag.id, false %> #should be > > checked according to sent params. > > <%=h tag.name %> > > <% end %> > > > > books.rb > > # attributes > > has author.taggings.tag(:id), :as => :tag_ids > > > > search_controller.rb > > @books = Book.search params[:q], :conditions => { :tag_ids => > > params[:tag_ids] } > > How is this approach not working? > > The basic technique should be valid, however: > > Check the value of params[:tag_ids] in your controller to ensure > it contains the tag ids you expect. > > Do you want all books that match any of the tags (an OR query) or books > that match all the tags (an AND query)? > > The default is OR, if you want an AND query, try: > > Book.search params[:q], :with_all => { :tag_ids => params[:tag_ids] } > > -- James Healy <jimmy-at-deefa-dot-com> Wed, 15 Apr 2009 20:42:39 +1000 > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAknluwYACgkQ4oawkrbYo/lXewCfdD5UW6VVSHKdtg8WkP8vT/JF > ds8AnRdmyZy787E0+Ply6bEtBo2GIANi > =LHyM > -----END PGP SIGNATURE----- > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
