Hi all,
Ran in to a problem with AR::B#find(:include) and acts_as_paranoid,
well described here:
http://www.ruby-forum.com/topic/57945
So I whipped up this thing, which seems to work for me:
module ActiveRecord
class Base
def self.has_one_paranoid(*args)
ref = create_has_one_reflection *args
cond = args.last[:conditions]
cond = cond.blank? ? '''' : cond + ''
AND''
cond << " (#{ref.table_name}.deleted_at IS NULL OR
#{ref.table_name}.deleted_at >
''#{Time.now.to_s(:db)}'')"
args.last[:conditions] = cond
has_one *args
end
end
end
I have two questions about it: 1) where''s a good place to post it to
get it into trunk, rubyforge''s tracker didn''t seem too lively.
2) are
there any spots where I should be doing it differently? I''m not
familiar with AR''s best practices.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---