On Oct 6, 7:59 pm, Mark Ma <[EMAIL PROTECTED]> wrote:
> can anyone tell me how before filter can call the private method audit
> which from the parent class ?
> because the bank controller has a private method called audit, this one
> should not be inheritance by VaultController, so how the before_filter
> use the private method audit ?
>
First off, private/protected probably does not mean what you think it
does (ie it's not the same as in C++ or java).
For example:
class A
private
def a_private_method
puts "hi"
end
protected
def a_protected_method
puts "ho"
end
end
class B< A
def foo
a_private_method
end
def bar
A.new.a_private_method
end
def baz
A.new.a_protected_method
end
end
B.new.foo #=> "hi"
B.new.bar #=> NoMethodError: private method `a_private_method' called
for #<A:0x6452c>
B.new.baz #=> "ho"
On top of that, filters eventually use the send method, which ignores
protected/privateness
Fred
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---