Route redirecting issue with devise and rails
<p>I have a <code>has_one</code> association in my model with my user. What I'm trying to do here is simple but I'm having a hard time understanding whats wrong here. So since I have a has_one association with my model, in my mind I was simply thinking that if the user has already created the model associated with the <code>has_one</code> association if he tries accessing <code>"localhost3000/model/new"</code> I would redirect him to the edit page of this particular model. Here is what I have but its telling me its not working as intended. It's as if my if statement is not catching anything</p>

<pre><code>class BusinessesController &lt; ApplicationController
  before_action :set_business, only: [:show, :edit, :update, :destroy]

  def index
    @businesses = Business.all
    @buzzs = Buzz.all
  end

  def show
  end

  def new
    if current_user.business.nil?
      @business = current_user.build_business
    else
      render 'edit'
    end
  end

  def edit
  end

  def create
    @business = current_user.build_business(business_params)

    if @business.save
      redirect_to @business, notice: 'Business was successfully created.' 
    else
      render "new"
    end
  end
</code></pre>

<p>This error does not make a lot of sense to me because it says its an error in the "new" controller which would have rendered it to the edit path thus not being nil</p>

<p><a href="https://i.stack.imgur.com/60WBC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/60WBC.png" alt="enter image description here"></a></p>