title: Guard clause instead of wrapping the code inside a conditional expression Rails
body: <p>There is the following code:</p>
  
  <pre><code># API controller for authentication
  class Api::V1::SessionsController &lt; Api::V1::ApplicationController
    skip_before_action :authorize
  
    def create
      @user = User.find_by(email: params[:user][:email])
      unless @user &amp;&amp; @user.authenticate(params[:user][:password])
        @error_message = 'Invalid username or password'
        render 'shared/error', status: :unauthorized
      end
    end
  end
  </code></pre>
  
  <p>I use Rubocop to check my code if it matches to Ruby guidelines. I got the following error:</p>
  
  <pre><code>Use a guard clause instead of wrapping the code inside a conditional expression.
      unless @user &amp;&amp; @user.authenticate(params[:user][:password])
  </code></pre>
  
  <p>So, I don't understand how I can make this code better using guard clause. Thanks in advance!</p>