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 ?
if the child class can use the parent class private method . does it break encapsulation ? does the private has any sense here .because you can use it from ur child class , why just make it public ? below is the example from rail api. Controller inheritance hierarchies share filters downwards, but subclasses can also add or skip filters without affecting the superclass. For example: class BankController < ActionController::Base before_filter :audit private def audit # record the action and parameters in an audit log end end class VaultController < BankController before_filter :verify_credentials private def verify_credentials # make sure the user is allowed into the vault end end Now any actions performed on the BankController will have the audit method called before. On the VaultController, first the audit method is called, then the verify_credentials method. If the audit method renders or redirects, then verify_credentials and the intended action are never called. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---