Re: Overwrite active_record find?

Frederick Cheung
Thu, 29 May 2008 13:39:51 -0000

On 29 May 2008, at 14:05, Christian Kerth wrote:

>
> Frederick Cheung wrote:
>
>> Should have been obvious - it looks like you''re not returning
the
>> right value (ie the result) from find_by_sql. Also bear in mind that
>> find will call find_by_sql in some cases, so make sure whatever
>> locking mechanism you''re using will support that.
I''ve got a hint
>> of a
>> doubt that by background task you mean a separate process, in which
>> case you''re out of luck (because each process would have its
own
>> lock).
>
> I switched the locking mechanism to thread.exclusive, because a mutex
> doesn''t work because find is calling find_by_sql. Added the
returns.
>
>
>
> By background task is a second thread, not a seperate process, so the
> locking mechanism should work.
>
> Is every find call using find_by_sql to retrieve data? Would it be
> enough to syncronize just find_by_sql then?
>
Almost all. a find with an :include doesn''t in rails 2.0.2. This sort
of thing could change in the future though.

Fred
> thx
> --
> Posted via http://www.ruby-forum.com/.