title: Mailer won't send email due to possible unmatched constraints: [:id]
body: <p>I'm working on a project for my school and when Students sign up, they must check their email for a link to activate their account. For around 10 students out of nearly 300, the email wasn't sent.</p>
  
  <p>The logs show: </p>
  
  <pre><code>ActionView::Template::Error: No route matches {:action=&gt;"edit", :controller=&gt;"account_activation", :email=&gt;"example@gmail.com", :id=&gt;nil}, possible unmatched constraints: [:id]
  from app/views/user_mailer/account_activation.html.erb:9:in _app_views_user_mailer_account_activation_html_erb___3703118489382282531_47409448002620' from app/mailers/user_mailer.rb:6:inaccount_activation'
  from app/models/user.rb:58:in `send_activation_email'
  from (irb):3
  </code></pre>
  
  <p>No matter what I tried, I couldn't recreate the error (I changed the email for privacy)</p>
  
  <p>users_controller.rb</p>
  
  <pre><code>def create
      @user = User.new(user_params)
      if @user.save
        @user.send_activation_email
        flash[:info] = "Please check your email to activate your account"
        redirect_to root_url
      else
        render 'new'
      end
    end
  </code></pre>
  
  <p>User.rb</p>
  
  <pre><code>    def send_activation_email
          UserMailer.account_activation(self).deliver
      end
  </code></pre>
  
  <p>user_mailer.rb</p>
  
  <pre><code>  def account_activation(user)
      @user = user
      mail( :to =&gt; @user.email, :subject =&gt; 'Account Activation | Student', :id =&gt; @user.activation_token)
    end
  </code></pre>
  
  <p>My account_activation_controller.rb</p>
  
  <pre><code>def edit
          user = User.find_by(email: params[:email])
          if user &amp;&amp; !user.activated? &amp;&amp; user.authenticated?(:activation, params[:id])
              user.activate
              log_in user
              flash[:success] = "Account activated!"
              redirect_to user
          else
              flash[:danger] = "Invalid activation link"
              redirect_to root_url
          end
      end
  </code></pre>
  
  <p>My github is <a href="https://github.com/Conbonbot/Community_Service_Logger" rel="nofollow noreferrer">https://github.com/Conbonbot/Community_Service_Logger</a></p>
  
  <p>Any help would be greatly appreciated</p>