title: Difference between "super" and "super do |u|" using context of Devise
body: <p>Ok so I think I get what super <code>does</code> standalone. Basically in Devise, if <code>Users::RegistrationsController &lt; Devise::RegistrationsController</code>, then on any action, having a <code>super</code> will first call the logic for that same named action in the parent <code>Devise::RegistrationsController</code>, before then calling what you've written.</p>
  
  <p>In other words...</p>
  
  <pre><code>class Devise::RegistrationsController
    def new
      puts "this is in the parent controller"
    end
  end
  
  class Users::RegistrationsController &lt; Devise::RegistrationsController
    def new
      super
      puts "this is in the child controller"
    end
  end
  
  # Output if users#new is run would be:
  # =&gt; "this is in the parent controller"
  # =&gt; "this is in the child controller"
  
  # If super were reversed, and the code looked like this
  # class Users::RegistrationsController &lt; Devise::RegistrationsController
    #  def new
      #  puts "this is in the child controller"
      #  super
    #  end
  #  end
  # Then output if users#new is run would be:
  # =&gt; "this is in the child controller"
  # =&gt; "this is in the parent controller"
  </code></pre>
  
  <p>What I'm curious about is that I've seen some people do this:</p>
  
  <pre><code>class Users::RegistrationsController &lt; Devise::RegistrationsController
    def new
      super do |user|
        puts "something"
      end
    end
  end
  </code></pre>
  
  <p>I'm having a hard time wrapping my head around what the <code>do block</code> is accomplishing. In my case, after the resource (the user) is created, I want to call an additional method on that resource (the user). </p>
  
  <p>Current code:</p>
  
  <pre><code>class Users::RegistrationsController &lt; Devise::RegistrationsController
    def new
      super do |user|
        user.charge_and_save_customer
        puts user.inspect
      end
    end
  end
  </code></pre>
  
  <p>I'm just wondering if this would be any different than doing:</p>
  
  <pre><code>class Users::RegistrationsController &lt; Devise::RegistrationsController
    def new
      super
      resource.charge_and_save_customer
      puts resource.inspect
    end
  end
  </code></pre>
  
  <p>In case it's helpful, I've included the parent <code>Devise::RegistrationsController</code> code below:</p>
  
  <pre><code>def new
    build_resource({})
    set_minimum_password_length
    yield resource if block_given?
    respond_with self.resource
  end
  </code></pre>