title: Rails Beta invitations - Overriding Devise Registration Controller
body: <p>I use Devise (1.4.8) for my User model and have been trying to implement a simple beta invitation feature (Rails 3.0.7), following Ryan Bates's <a href="http://railscasts.com/episodes/124-beta-invitations" rel="nofollow">railscast</a>. </p>
  
  <p><strong>I can't get the [new] method of my devise model's controller to recognize the invitation token.</strong> I suspect this is because I am not succesfully overriding the registrations controller of Devise. </p>
  
  <p>I am assuming instead of the using the user_controller for passing variables from registration form, I have to override devise's registrations controller. So my registrations_controller.rb in the root of controllers folder:</p>
  
  <pre><code>class RegistrationsController &lt; Devise::RegistrationsController
    def new
      super
      @user = User.new(:invitation_token =&gt; params[:invitation_token])
      @user.email = @user.invitation.recipient_email if @user.invitation
    end
  end
  </code></pre>
  
  <p>In routes.rb:</p>
  
  <pre><code>devise_for :users, :controllers =&gt; {:registrations =&gt; 'registrations'} do
    get 'users/sign_up/:invitation_token' =&gt; 'devise/registrations#new', :as =&gt; "new_user_registration"
  end
  </code></pre>
  
  <p>In invitation_controller.rb</p>
  
  <pre><code>Mailer.invitation(@invitation, new_user_registration_url+"/#{@invitation.token}").deliver
  </code></pre>
  
  <p><strong>How I can override Devise's registration controller and pass the :invitation_token successfully from Devise's new user form?</strong></p>