title: What is this syntax inside ruby clases?
body: <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery #What is this syntax? When is this executed and how to create one?
  end
  
  class Comment &lt; ActiveRecord::Base
    belongs_to :post
    attr_accessible :body, :commenter, :post
  end
  </code></pre>
  
  <p>In the first case,  I understand ApplicationController is a new Derived class of class called <code>Base</code> in the module ActionController. What happens in the next line? Is <code>protect_from_forgery</code> a method in base class or in module ActionController? What is it called? I couldn't find in ruby classes documentation. I tried creating a method in base class but got errors like below. How do I create such special commands which can be used in a class?</p>
  
  <pre><code>class Base
    def foo
      @name = "foo"
    end
  end
  
  class Der &lt; Base
    foo
    def bar
      @dummy = "bar"
    end
  end
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>expr1.rb:62:in `&lt;class:Der&gt;': undefined local variable or method `foo' for Der:Class (NameError)
      from expr1.rb:61:in `&lt;main&gt;'
  </code></pre>