Topic: acts_as_ferret Search broken after upgrade?!?! HELP!

I was following this tutorial, because it sounded like what i wanted. 

The problem with the tutorial, is that they take for granted you know fully what you are doing.  I thought I was following along pretty well, until i added

require 'acts_as_ferret'

to environment.rb

i now get this message when i try and restart the server

/Users/superguy/rails/loseit/vendor/plugins/acts_as_ferret/init.rb:23:in `evaluate_init_rb': undefined method `load_config' for ActsAsFerret:Module (NoMethodError)

when i pick through the code, I see the method should be set, but it isn't initializing.

Has anyone else had problems as such? speak up please, i'm all ears.

I'll post whatever you need to make this work. 

I've also updated the following ferret gem, acts_as_ferret gem and acts_as_ferret plugin.  they are all the most current versions.

why won't this pig initialize?

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

well i think the version I got from svn was either borked or aaf is borked currently.

will check back again. and i'm going to wait.  the features that they are implementing are looking fantastic.  i hope....

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

private method `initialize' called for ActsAsFerret:Module (NoMethodError)

my script/server 'log' is spitting this message out when i add:

  config.after_initialize do
    ActsAsFerret.initialize
  end

to my config/environment.rb file.

just for a reminder

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

chipes... I uninstalled everything that ever touched acts_as_ferret.

i reinstalled the plugin.  followed the tutorial and am now just trying to get my views to work.

I wish there was a way to view if @results is actually working.  That way, i don't spend time dinking around with views, and can concentrate on the controller actions instead.

anyways... hope to have more soon.

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

i'm at work now, but will post code this evening.

what portions would you like?  screw it, i'll post the whole thing.

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

Post your controller and view. That should be fine for a beginning.

Damon Torgerson
www.uncleross.com

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

First, here is my aaf.rb file

ActsAsFerret::define_index('comeonworkjerk',
:models => {
   Product  => {:fields => [:name, :company]},
   Post    => {:fields => [:title, :body]}
},
:ferret   => {
   :default_fields => [:name, :company, :title, :body]
}
)

i'm using a _menu.html.erb partial inside my layout in layout/application.html.erb
_meni.html.erb
            <li><% form_tag search_search_path, :method => :get do %>
            <%= text_field_tag 'q', params[:q], :style => "width: 50%" %>
            <%= submit_tag "Search!", :name => nil %>
            <% end %></li>

in my search_controller.rb
class SearchController < ApplicationController
  def index
  end
 
  def search
    @results = ActsAsFerret.find(params[:q], 'comeonworkjerk')
  end
end

in my view, which i keep in search/search.html.erb
<h1>Search Results for "<%=h params[:q] %>"</h1>

<%= render :partial => 'search' %>
<%= @results.inspect %>
<ul>
  <% @results.each do |result| %>
    <%= render :partial => "#{dom_class(result)}", :object => result %>
  <% end %>
</ul>


search/_post.html.erb
<li><%= post.body %></li>

search/_product.html.erb
<li><%= product.company %></li>

Last edited by nerb (2008-05-18 10:28:15)

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

Which server are you talking about: web server or search (ferret) server?

I don't get any unusual messages from loading either.

I've subscribed to this topic so hopefully I'll get notified when you post so it won't be so long in the future.

Damon Torgerson
www.uncleross.com

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

thanks dtorgerson.

when i start mongrel, and i look at my terminal, when mongrel loads up, it spits out those messages.  In the demo app that was created in the tutorial, the last few mongrel lines are as follows:

SQL (0.000366)    SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

configured index for class Company:
{:mysql_fast_batches=>true, :single_index=>false, :index_base_dir=>"/Users/nerb/Downloads/ferret-example/index/development/shared", :reindex_batch_size=>1000, :models=>{Post(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime)=>{:fields=>[:title, :body]}, Person(id: integer, first_name: string, last_name: string, phone: string, bio: text, created_at: datetime, updated_at: datetime)=>{:fields=>[:first_name, :last_name, :phone, :bio]}, Company(id: integer, name: string, description: text, created_at: datetime, updated_at: datetime)=>{:fields=>[:name, :description]}}, :name=>:shared, :registered_models=>[Post(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime), Person(id: integer, first_name: string, last_name: string, phone: string, bio: text, created_at: datetime, updated_at: datetime), Company(id: integer, name: string, description: text, created_at: datetime, updated_at: datetime)], :ferret=>{:auto_flush=>true, :key=>[:id, :class_name], :or_default=>false, :path=>"/Users/nerb/Downloads/ferret-example/index/development/shared", :handle_parse_errors=>true, :create_if_missing=>true, :default_field=>[:description, :name, :first_name, :title, :phone, :last_name, :bio, :body], :default_fields=>[:first_name, :last_name, :phone, :bio, :name, :description, :title, :body]}, :raise_drb_errors=>false, :ferret_fields=>{:description=>{:via=>:description, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :name=>{:via=>:name, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :first_name=>{:via=>:first_name, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :title=>{:via=>:title, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :phone=>{:via=>:phone, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :last_name=>{:via=>:last_name, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :bio=>{:via=>:bio, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}, :body=>{:via=>:body, :boost=>1.0, :index=>:yes, :store=>:no, :highlight=>:yes, :term_vector=>:with_positions_offsets}}, :user_default_field=>nil, :enabled=>true, :index_dir=>"/Users/nerb/Downloads/ferret-example/index/development/shared"}


when start mongrel in my own app, using his code, but customized for my models i get this output in the log (terminal output):
SQL (0.001385)   SHOW TABLES
  SQL (0.001333)   SHOW TABLES
  SQL (0.001324)   SHOW TABLES
  SQL (0.001369)   SHOW TABLES
configured index for class Post:
{:raise_drb_errors=>false, :ferret_fields=>{:company=>{:index=>:yes, :term_vector=>:with_positions_offsets, :store=>:no, :highlight=>:yes, :boost=>1.0, :via=>:company}, :name=>{:index=>:yes, :term_vector=>:with_positions_offsets, :store=>:no, :highlight=>:yes, :boost=>1.0, :via=>:name}, :title=>{:index=>:yes, :term_vector=>:with_positions_offsets, :store=>:no, :highlight=>:yes, :boost=>1.0, :via=>:title}, :body=>{:index=>:yes, :term_vector=>:with_positions_offsets, :store=>:no, :highlight=>:yes, :boost=>1.0, :via=>:body}}, :user_default_field=>nil, :enabled=>true, :index_dir=>"/Users/nerb/rails/loseit/index/development/comeonworkjerk", :name=>:comeonworkjerk, :mysql_fast_batches=>true, :single_index=>false, :models=>{Product(id: integer, name: string, url: string, image: string, description: string, created_at: datetime, updated_at: datetime, color: string, company: string)=>{:fields=>[:name, :company]}, Post(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime, blog_id: integer, url_slug: string)=>{:fields=>[:title, :body]}}, :index_base_dir=>"/Users/nerb/rails/loseit/index/development/comeonworkjerk", :reindex_batch_size=>1000, :registered_models=>[Product(id: integer, name: string, url: string, image: string, description: string, created_at: datetime, updated_at: datetime, color: string, company: string), Post(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime, blog_id: integer, url_slug: string)], :ferret=>{:default_field=>[:company, :name, :title, :body], :auto_flush=>true, :key=>[:id, :class_name], :path=>"/Users/nerb/rails/loseit/index/development/comeonworkjerk", :default_fields=>[:name, :company, :title, :body], :or_default=>false, :handle_parse_errors=>true, :create_if_missing=>true}}

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

I also put the code in, for post seven above. thanks.

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

What version of Rails are you working in?

Damon Torgerson
www.uncleross.com

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

2.0.2

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

okay, one thing that I did was move my search into my search out of my controller and into my model.

def do_search(per_page, page)
    return ActsAsFerret::find(query, [Organization, Activity], :per_page => per_page, :page => page)   
end

This allowed me to run very basic tests to inspect the returned object. So one of my unit tests looks like this
  def test_search_activities
    act = activities(:river_rafting)
    s = Search.new("river")
    assert s
    assert s.instance_of?(Search)
    results = s.do_search(5,1)
    assert results
    assert results.instance_of?(Array)
    puts results.per_page
  end

This allowed me to focus on the search and not worry about controllers or views. As you can see, the key for me was determining that an array was being returned instead of a SearchObject.

I'll have a look but if you haven't, I highly recommend you move search to your search model (not an ActiveRecord object in my case)

Last edited by dtorgerson (2008-05-18 22:19:53)

Damon Torgerson
www.uncleross.com

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

well to add another wrinkle... it worked now?

i don't know why.  coding by coincidence but it worked!

i created a user called imhorny and now it finds that user name.  I don't know if it was the user name that did it or not, but i don't think i did anything different.

success.

i know i'll be back, and maybe when i add more models, i'll try your suggestion.
thanks for seeing me through this.

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

Congratulations! If you haven't done so already, you may want to write up some tests just to try and get more predictable behaviour.

Damon Torgerson
www.uncleross.com

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

well i havent' done tests ever... and i'm well over 1000  lines of code... gulp.  however, i'm stripping my app down to the frame, so i can build it up again, now that i "know" hehehe, like i Know!, what i'm doing.

good advice, one i will implement.

thanks again boss.  best of luck.  maybe i can help you someday.

Re: acts_as_ferret Search broken after upgrade?!?! HELP!

Regarding the problem above:

undefined method `load_config