|
|
Subject: Multi select with conditions - msg#00019
List: lang.ruby.ferret.general
Hi I'm doing a multi-model search like this, which works absolutely fine: @search_results = ActsAsFerret::find( "trumpet", [Resource, Lesson, Course], #(ferret) options
{ :page => 1, :per_page => 20, :sort => Ferret::Search::SortField.new(:name, :reverse => false)
}, #find options {} ) My new problem is that the results need to be restricted: basically any user has only limited access to certain lessons, resources and courses, depending on their shared priveleges. I have methods to produce arrays of ids of each that the user is allowed to see, eg
@user.allowed_lessons => array of ids of all lessons the user has access to Can anyone show me how to incorporate this into my search? I have the feeling that i can do something with the :conditions options, which can be passed through in the find options hash. But i can't work it out: i tried this:
:conditions => [" lesson.id in (?) or course.id in (?) or resource.id in (?)", @user.allowed_lessons, @user.allowed_courses, @user.allowed_resources]
But it doesn't work: it says 'no such field as lesson.id in resources'. I feel like this should be possible - can anyone help? thanks max
_______________________________________________
Ferret-talk mailing list
Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/ferret-talk
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: find_with_ferret :multi not working for me (latest version) (apologies if this was already posted)
I just remembered the second part of my last question...I have a superclass, Resource, which has two subclasses, TeachingObject and LearningObject. All the records that are saved are one of the subclasses. However, i'd like to be able to do a ferret search on Resource and get both kinds of subclass, like when i do Resource.find(), which returns both kinds.
I'm having problems with the index though: TeachingObject and LearningObject both have :store_class_name => true, and they have their own indexes. When i try to build the index for Resource, it crashes with the following trace, whether i have :store_class_name => true set for Resource or not. Any ideas, anyone?
thanks, maxNoMethodError: You have a nil object when you didn't expect it!The error occurred while evaluating nil.each_pair from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:130:in `to_doc'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/object/misc.rb:28:in `returning' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:124:in `to_doc'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:in `index_records' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:in `each'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:in `index_records' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:29:in `measure_time'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:18:in `index_records' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:52:in `index_model'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:79:in `records_for_rebuild' from /home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/active_record/transactions.rb:80:in `transaction' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:74:in `records_for_rebuild'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:51:in `index_model' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:in `index_models'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:in `each' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:in `index_models'
from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/local_index.rb:54:in `rebuild_index' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:28:in `rebuild_index'
_______________________________________________
Ferret-talk mailing list
Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/ferret-talk
Next Message by Date:
click to view message preview
ignoring 'accents' when i search
Does anyone know of a way of being 'accent-insensitive' when i do a search? For example, if i have a resource with the name "La BohÃme", and someone searches for 'boheme' i want them to find that resource, even though the 'e' doesn't have the accent. At the moment, it will only find it if they search for the properly accented version.
I guess soundex support for ferret is what I mean, but maybe there's another way?thanks, max
_______________________________________________
Ferret-talk mailing list
Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/ferret-talk
Previous Message by Thread:
click to view message preview
ferret (search application)
hi, This is pravin. i am trying to make search application in ROR for that i have installed ferret & acts_as_ferret pluginbut , i got the following error Processing SearchController#search (for 127.0.0.1 at 2008-04-15 12:49:54) [GET]
Session ID: ae2547277cd00cf930f79afdbc8c8b61 Parameters: {"action"=>"search", "q"=>"Tata Consultancy Services Pune", "controller"=>"search"}Asked for a remote server ? true, ENV["FERRET_USE_LOCAL_INDEX"] is nil, looks like we are not the server
Will use local index.using index in ./script/../config/../index/development/detaildefault field list: [:name]Query: Tata Consultancy Services Punetotal hits: 0, results delivered: 0Rendering search/search
Rendered search/_search_form (0.00167)Completed in 0.00878 (113 reqs/sec) | Rendering: 0.00243 (27%) | 200 OK [http://localhost/search/search?q=Tata+Consultancy+Services+Pune]
pravin
_______________________________________________
Ferret-talk mailing list
Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/ferret-talk
Next Message by Thread:
click to view message preview
ignoring 'accents' when i search
Does anyone know of a way of being 'accent-insensitive' when i do a search? For example, if i have a resource with the name "La BohÃme", and someone searches for 'boheme' i want them to find that resource, even though the 'e' doesn't have the accent. At the moment, it will only find it if they search for the properly accented version.
I guess soundex support for ferret is what I mean, but maybe there's another way?thanks, max
_______________________________________________
Ferret-talk mailing list
Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/ferret-talk
|
|