Hi folks,
big problem
u = User.username_like('hans').first
# works
u.projects
# error undefined "local variable or method" for project
What's wrong with that?
Model Code
class User
has_many :projects
end
Class Project
belongs_to :owner, :class_name => "User", :foreign_key => "user_id"
end
please help, thanks in advance :)
...
I have the following associations:
class BookShelf {
has_many :books
}
class Book {
has_many :pages
belongs_to :book_shelf
}
class Page {
belongs_to :book
}
If I have a BookShelf object, how could I use searchlogic to search pages that belong to the books in the current book shelf?
Currently I'm using this one:
@bookshelf ...
Hi,
I just installed searchlogic 2.4.24 for my Rails 2.1.0 app but got the following error :-
..aliasing.rb:31:in alias_method':NameError: undefined methodmerge_joins' for class `Class'
Is it a version conflict? Does anyone know which version of searchlogic works with Rails 2.1.0?
Thanks!
...
My form
<% form_for @search do |f| %>
<%= f.input :name_like_any %>
...
<% end %>
Controller
@search = Product.search
@search.name_like_any(params[:search][:name_like_any].split(/\s+/))
@products = search.all
This returns the correct result, but now my form shows the name as ["foo", "bar"] instead of what the user input ("foo b...
Here is what I'm trying:
app/models/product.rb
class Product < ActiveRecord::Base
class << self
def searchlogic(conditions = {})
ProductSearch.new(self, scope(:find), conditions)
end
end
end
app/models/product_search.rb
require "searchlogic/search"
class ProductSearch < SearchLogic::Search
include SearchLogic
...
When I chain searchlogix conditions that associate different tables, the results duplicate.
When I chain searchlogix conditions querying fields from a single table, the results work perfectly.
Below is an example of chaining conditions across multiple tables (machine belongs to a manufacturer and machine habtm tools and systems).
Mach...
Example form
<% form_for @search do |f| %>
<ul>
<li>
<%= f.label :item_number_equals, "Item number" %><br />
<%= f.text_field :item_number_equals %>
</li>
<li>
<%= f.label :description_keywords, "Description" %><br />
<%= f.text_field :description_keywords %>
</li>
<li>
<%= f.check_box...
If not what are my alternatives?
...
My search form is triggering this.
undefined method `id_like_before_type_cast' for #<Class:0xb5ffff68>
Here's the line from the form:
<%= f.text_field :id_like %>
...
I have two models Employee & Unit. Unit has many Employees. I am using SearchLogic to search employee model. What is the equivalent of below SQL in Searchlogic
employees.unit_id IN (1,2,3)
I have tried both
unit_id_equals_all[]
unit_id_equals_any[]
But nothing works. Can anyone help?
Thanks, Abhilash
...
Scenario:
:author has_many :posts
My searchlogic-based web form search for authors:
f.text_field :name_like # author name
f.text_field :posts_title_like # post title
searchlogic named scopes use inner joins, so I'll only get authors returned if they have posts. Authors without posts are not returned.
How do I force an outer join w...
Contact belongs_to status_contacts
I only want those Contacts where no value has been assigned.
I installed the searchlogic plugin.
I tried:
contacts = Contact.status_contact_null
And got an error.
How can I get a full sense of how to use associations with searchlogic, and how can I use it for this particular search?
...
I am trying to setup searchlogic on nested resources. I have Category has_many :products also Category has_many :brands through :products
So structurally its Category/Brand/Product
As a user navigates the site they click a category, which uses the Category#show action.
#Category_controller
def show
@category = Category.find_by_u...
I have a searchlogic that searches for not_null on an association that can occur many times, but I only want to display one UNIQUE/DISTINCT instance of the object:
Company.contact_emails_id_not_null
I only want one Company, no matter how many contact_emails are associated to that Company :through => :contacts
...
I want to do the equivalent of (A<y AND B>x) OR (C < y AND D>x). how can i do that?
Right now, I am creating separate queries:
@companies_with_email = Company.contact_emails_date_sent_gt(@monday).
contact_emails_date_sent_lt(@friday).
find(:all, :select => "distinct companie...
I am using the gem Searchlogic for Rails. Everything is working great. The only question I have left is how to have an element display, after the query, that says something like:
Search Results for "whatever"
I can't find anything in the docs. Anyone have suggestions? Here is my code:
/posts/index.html.erb
<% form_for @search do |f...
I put searchlogic in my gemfile... and now my rails server won't start :(
this is the errormessage
gems/ruby-1.8.7-p299/gems/activesupport-3.0.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `merge_joins' for class `Class' (NameError)
from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/activesup...