Can you override a private rails method?


#1

I’m trying to override the behavior of find_with_associations for an
acts_as
plugin.

Not having much luck as it’s a private method, so I can’t alias it, and
my
method
of the same name is ignored.

Is this even possible?

joshua


#2

In the ruby example below, it looks like you can override a private
function. Can you post code?

-Peter

class A
private
def foo
“foo”
end
end

class A
private
def foo
“foofoo”
end

public
def bar
foo
end
end

a = A.new
puts a.bar # outputs “foofoo”


#3

In the process of grabbing my code to post, I solved it!!!

I had to include the methods straight into ActiveRecord::Base not into
ActiveRecord::Associations

eg
ActiveRecord::Base.send :include,
Democracy::Acts::Multilingual::Associations

I was worried that it just wasn’t possible, because doing something as
simple as this doesn’t work

module ActiveRecord
module Associations
private
def association_join(*args)
breakpoint
super
end
end
end