> Looks as though attributes from many to many relationships are not being 
> added to the index when a record is amended.

I have the following relationship between documents and topics:



class Document < ActiveRecord::Base
  acts_as_ferret :additional_fields => [:topic_titles]

  has_many :document_topics, :dependent => true
  has_many :topics, :through => :document_topics

  def topic_titles
    topics.collect { |topic| topic.title }.join ' '
  end
end

class Topic < ActiveRecord::Base
  has_many :document_topics, :dependent => true
  has_many :documents, :through => :document_topics
end


The update action in documents_controller.rb looks like this:

  def update
    params[:document][:topic_ids] ||= []
    @document = Document.find(params[:id])
    @topics = (params[:topics] or []).collect { |item| item.to_i }
    @document.attributes = params[:document]
    @document.topic_ids = @topics
    @document.save

    if @document.update_attributes(params[:document])
      flash[:notice] = 'Document was successfully updated.'
      redirect_to :action => 'show', :id => @document
    else
      render :action => 'edit'
    end
  end

I suspect there is something here which means the document has no topics 
when acts_as_ferret attempts to add the topic_titles to the index.

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to