Search two related tables

Hi, It would be trulely appreciated if anyone can give me some advise on
this.
I have two related tables titles and authors. Using acts_as_ferret, I
can search by title name. However, when search by author name or ausname
in this case, I only get “sorry, found 0 item”.

class Title < ActiveRecord::Base
acts_as_ferret :additional_fields => [:author_name]
belongs_to :author

def author_name
return author.ausname
end

class Author < ActiveRecord::Base
has_many :titles
end

def search
if params[:q]
query = params[:q]
@titles = Title.find_by_contents(query)
unless @titles.size > 0
flash.now[:notice_not_found] = “Sorry, found 0 item”
end
render :action => ‘search_result’
end
end

On Fri, Apr 18, 2008 at 01:25:49PM +0200, Katsuo I. wrote:

Hi, It would be trulely appreciated if anyone can give me some advise on
this.
I have two related tables titles and authors. Using acts_as_ferret, I
can search by title name. However, when search by author name or ausname
in this case, I only get “sorry, found 0 item”.

Did you have a look at your log files? Maybe author is nil when
acts_as_ferret calls the author_name method. Aaf logs every field and
value it adds to the index so you should pretty easily find out what’s
going on.

Cheers,
Jens


Jens Krämer
Finkenlust 14, 06449 Aschersleben, Germany
VAT Id DE251962952
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs