title: Why is this variable in this block for this validation code empty?
body: <p>I'm using Devise and I'm trying to set up an invite code that the user has to input in order to sign up. I have this code in my user model:</p>
  
  <pre><code>attr_accessor :invite_code
  
  validates_each :invite_code, :on =&gt; :create do |record, attr, value|
      record.errors.add attr, "is wrong" unless value == "12345"
  end
  </code></pre>
  
  <p>and this text field:</p>
  
  <pre><code>&lt;%= f.text_field :invite_code %&gt;
  </code></pre>
  
  <p>The problem is that <code>value</code> is always empty, so the validation is always failing, even if the invitation code is "12345".</p>
  
  <p>I'm guessing this might have to do with the fact that the file that contains the text field is not in the user directory but is in a separate registrations directory (I did this from following <a href="http://railscasts.com/episodes/236-omniauth-part-2" rel="nofollow">this railscast</a> when setting up omniauth). I'm really unsure though. How do I fix this?</p>
  
  <p>Here's more information:</p>
  
  <p>This is in my routes.rb: </p>
  
  <pre><code>devise_for :users, :controllers =&gt; { :registrations =&gt; 'registrations'}
  </code></pre>
  
  <p>this is in my users controller:</p>
  
  <pre><code>def new
    @user = User.new
  end
  
  def create
    @user = User.new(params[:user])
    if @user.save!
      redirect_to videos_path
    else
      render :action =&gt; 'new'
    end
  end
  </code></pre>
  
  <p>This is in my registrations controller:</p>
  
  <pre><code>def create  
    super  
    session[:omniauth] = nil unless @user.new_record?
  end
  </code></pre>