Re: Overwrite active_record find?

Frederick Cheung
Thu, 29 May 2008 12:43:40 -0000

On 29 May 2008, at 13:34, Christian Kerth wrote:

>
> Frederick Cheung wrote:
>
>> You need to say super(*args). alias_method_chain is usually a more
>> prudent choice for this sort of stuff (and i assume you know that
>> this
>> won''t accomplish anything if you''re using a pack of
mongrels or
>> whatever - I suppose it would work if you had a single multithreaded
>> script, but I''m still not sure what the point would be)
>>
>> Fred
>
> Problem is I''m using active_record without rails on a application
that
> includes a mini http server (built on top of webrick) and a background
> task. Both operate on the same sqlite db. Because of concurrency
> issues
> with sql I''m trying to synchronize access to the database.
>
> Iven with super(*args) i still get the error:
>
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).

Fred
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
> base.rb:1227:in
> `find_initial'': undefined method `first'' for nil:NilClass
> (NoMethodError)
>        from
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
> base.rb:1514:in
> `send''
>        from
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
> base.rb:1514:in
> `find_by_requesttype_and_requeststatus''
>
> --
> Posted via http://www.ruby-forum.com/.