Finding a record to edit with logic in Rails
<p>I am having trouble with the edit method on my Rail app. It was working until I started adding some logic to it.
I have a view with a link to the controller that should search the db and if a record exists for that user and that fixture redirects to the edit action and allow the user to edit the record if not then it redirects to the new action.
The action coming in is teamentry.</p>

<pre><code>  before_action :find_submisionedit, only: [:edit]
  def teamentry
    @venue = params[:fixture]
  if (Submission.exists?(:user_id =&gt; current_user.id)) &amp;&amp; (Submission.exists?(:p1_venue =&gt; params[:fixture]))
    redirect_to action: "edit" , fixture: @venue
  else
    redirect_to action: "new" , fixture: @venue
  end
end
</code></pre>

<p>The new action works fine. The edit throws up errors.</p>

<p>I am trying to use a before action.</p>

<pre><code>def find_submisionedit
  @submission = Submission.where(user_id = current_user.id) &amp;&amp; (p1_venue =    params[:fixture])
end
</code></pre>

<p>I am getting a no method error.
Im guessing this is because the before action is not finding the correct information?</p>