For example this query:
SELECT `variants`.*
FROM `variants` INNER JOIN `variant_attributes`
ON variant_attributes.variant_id = variants.id
WHERE (variant_attributes.id IN ('2','5'))
And variant has_many variant_attributes
What I actually want to do is to find which variant has BOTH variant attributes with ID = 2 and 5. Is t...
I'd like to use searchlogic's scope_procedure feature like so
class MyModelObject < ActiveRecord::Base
scope_procedure :my_scope_proc, lambda { |p1, p2| { :conditions => "p1 >= #{p1} AND p2 < #{p2}" }}
end
Then, I am doing the search:
scope = MyModelObject.search(:my_scope_proc => true)
scope.all
The above code obviously doesn't...
Hi I have a post model that :has_many :reply, when using searchlogic, doing Post.reply_content_like("search"), returns a result for every reply under that post, I only want it to return once. Anyone know a way to solve this
...
Hey all,
I'mt not too familiar with searchlogic plugin for rails (I did view the railscasts but wasn't helpful in relation to the specific code below). Can anyone briefly describe how it is being used in the three methods below? Thanks for any response.
def extract_order
@order_by = if params[:order].present?
field = params[:order]...
Let's say I have the following model:
Person <AR
def name
[self.first_name,self.middle_name,self.last_name].select{|n| n.present?}.join(' ')
end
end
How could I do a search on the virtual attribute with searchlogic, something like:
Person.search.name_like 'foo'
Of courese I could construct a large statement like:
Person.search...
Especially when you are using Searchlogic. It is kinda hard for me to guess what named scope to use to achieve what I need.
...
Let's say I have:
class ForumTopic < ActiveRecord::Base
has_many :forum_posts
named_scope :number_of_posts, ??????
end
class ForumPost < ActiveRecord::Base
belongs_to :forum_topic
end
What should I put in ????? to allow searchlogic query like:
ForumTopic.descend_by_number_of_posts
Any help would be very greatly appreciated!
...
Is something like this possible?
Product.price_greater_than(10000).or_tags_name_equals('luxury')
The wiki doesn't help much on this...
I saw in the wiki:
User.id_or_age_lt_or_username_or_first_name_begins_with(10)
=> "id < 10 OR age < 10 OR username LIKE 'ben%' OR first_name like'ben%'"
I really don't get that, how in the worl...
Hi,
Can Searchlogic search with case insensitivity?
Thanks,
Jay
...
I'm using Searchlogic to search on many fields in a database. One of those fields is a :has_may, :through => relationship, and I can't get it to work.
Here are the relevant parts of the models:
Source.rb:
class Source < ActiveRecord::Base
has_many :authorships
has_many :authors, :through => :authorships
end
Authorship.rb:
clas...
Imagine case scenario, you have a list of recipes that have ingredients as a text.
You want to see how many recipes contain "sesame oil".
The problem with default searchlogic searching using Recipe.ingredients_like("sesame oil") is that any recipe with sesame AND oil would come up, when I'm searching for "sesame oil" which is a problem...
Hi guys, I have the following issue:
I have two classes in my rails app, joined by a HABTM association, like so:
#ad.rb
has_and_belongs_to_many :specs
#spec.rb
has_and_belongs_to_many :ads
joined by an ads_specs table.
I'm trying to perform a search on the Ad class using the excellent searchlogic gem. Everything went fine until I wan...
I'm using search logic to filter and order my results but it removes records from my results when I order by a association and when that association is not always present for all records.
For example say I have a user model which can have one vehicle model but does not have to, if I have a results table where you can order by the users ...
Does anyone have the same problem or a working solution?
I get always this error message, here are model, controller and view code
class Profile < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 10
end
def index
@search = Profile.search(params[:search])
@profiles = @search.paginate(:page => params[:page])
end
<%=...
I can't figure out why ascend_by won't work for me. Here's a console readout
>> tapes = Tape.search(:timestamp_gte => "1278361923")
=> blah blah blah
>> tapes.length
=> 1436
>> tapes.ascend_by_timestamp
=> nil
I get the same behavior when I use descend_by and other columns.
ruby 1.8.7
Rails 2.3.8
searchlogic 2.4.19
...
Hello again great knowledge masters of stackoverflow,
once again the small coder apprentice tabaluga is in need of help
The Goal : make the username sortable in the view. The difficulty is, that I am Querying Profiles in the controller ( Profile.username doesn't exist but Profile.user.username does). How Do I accomplish that? My Code so...
Is it possible to perform a multiple order_by while searching using Searchlogic?
What I want to do is to search somehow like this:
User.ascend_by_id.ascend_by_email
I saw a corresponding ticket: on github project page. But still would like to hack on that and somehow perform this find.
Is it possible?
...
I'm working on a Rails app wherein I want to be able to search for records created in a given year using the Searchlogic gem, but I can't figure out how to have Searchlogic only search by year. I tried this in my search form:
<%= f.date_select(:created_at_equals, :start_year => 2010, :end_year => 2015, :discard_day => true, :discard_mo...
I have model called VoteTopic with the following associations
belongs_to :user
belongs_to :category
has_many :comments
has_many :vote_items, :dependent => :destroy
has_many :votes, :through => :vote_items
I use Searchlogic gem to query for @vote_topics in the index action as follows..
scope_procedure :all_approved, lambda {status_equ...
This works:
Baseline Controller
@search = Baseline.search(params[:search])
@baselines = @search.paginate :page => params[:page], :per_page => params[:per_page]
baseline index view
<% form_for @search do |f| %>
<%= f.text_field :baseline_name_like_or_description_like %>
<%= submit_tag 'Search' %>
<% end %>
Where would I trim t...