Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: Re: Index not being updated - msg#00185
List: lang.ruby.ferret.general
>
> My index is not being updated when I add new records or amend existing
>
> ones.
>
>
>
> Can anyone point me in the direction of where I should be looking for
>
> what is going wrong?
>
>
>
> I'm running this in the production environment.
>
>
Is an amended record added to the index when .save is called?
Looks as though attributes from many to many relationships are not being
added to the index when a record is amended.
--
Posted via
http://www.ruby-forum.com/.
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Index not being updated
This is the same problem I am experiencing, but have not had time to
investigate it yet. I believe it is a bug.
Britt
On 11/28/06, Matthew Planchant <matt-oukN4rz81anRZ1oM81ef8Q@xxxxxxxxxxxxxxxx>
wrote:
> Matthew Planchant wrote:
> > My index is not being updated when I add new records or amend existing
> > ones.
> >
> > Can anyone point me in the direction of where I should be looking for
> > what is going wrong?
> >
> > I'm running this in the production environment.
>
> Is an amended record added to the index when .save is called?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
> http://rubyforge.org/mailman/listinfo/ferret-talk
>
Next Message by Date:
click to view message preview
Re: Index not being updated
> 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/.
Previous Message by Thread:
click to view message preview
Re: Index not being updated
This is the same problem I am experiencing, but have not had time to
investigate it yet. I believe it is a bug.
Britt
On 11/28/06, Matthew Planchant <matt-oukN4rz81anRZ1oM81ef8Q@xxxxxxxxxxxxxxxx>
wrote:
> Matthew Planchant wrote:
> > My index is not being updated when I add new records or amend existing
> > ones.
> >
> > Can anyone point me in the direction of where I should be looking for
> > what is going wrong?
> >
> > I'm running this in the production environment.
>
> Is an amended record added to the index when .save is called?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk-GrnCvJ7WPxnNLxjTenLetw@xxxxxxxxxxxxxxxx
> http://rubyforge.org/mailman/listinfo/ferret-talk
>
Next Message by Thread:
click to view message preview
Re: Index not being updated
> 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/.