On Thu, Nov 30, 2006 at 06:00:58PM +0100, Matthew Planchant wrote:
> I got this working by disabling ferret for a block like this:

glad to hear :-)

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

imho it would be better to not call update_attributes in this place, as
you already saved the document inside the block above.  It's one line
more for the explicit call to ferret_update but should save you one
update call to your DB.

so instead of this:
>     if @document.update_attributes(params[:document])

this should work, too:

      if @document.valid?     
        @document.ferret_update
>       flash[:notice] = 'Document was successfully updated.'
>       redirect_to :action => 'show', :id => @document
>     else
>       render :action => 'edit'
>     end
>   end

you could even store the return value from the save call inside the
block and use that in the if statement...

Jens


-- 
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       [EMAIL PROTECTED]
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to