title: ruby on rails can i use something like Model.find(params[:id]).where()
body: <p>Hi, I am still a student and I'm taking a software engineering course and we have this big project (web design) and we're using rails so my question is I have a table <code>Users</code> and a table <code>Groups</code> and another association table <code>GroupUsers</code> where it has two foreign keys <code>user_id</code> and <code>group_id</code>. Whenever a user creates or join an already created group his id and the group_id are added to <code>GroupUsers</code> table</p>
  
  <pre><code>module GroupUsersHelper
     def join
        @group_id = params[:id]
        @user_id = params[:user_id]
        @newuser= GroupUser.new(:group_id =&gt; @group_id, :user_id =&gt; @user_id)
        @newuser.save
        redirect_to(:controller =&gt; 'groups', :action =&gt; 'show', :id =&gt; @group_id)
     end
  end
  </code></pre>
  
  <p>Now I have to create method leave group where I'll have to destroy the record from <code>GroupUsers</code>, so I wrote this code also in <code>GroupUsersHelper</code></p>
  
  <pre><code>  def leave
        @group_id = params[:group_id]
        @user_id = params[:user_id]
        @group_user_id = params[:group_user_id]
        @newuser= GroupUser.find(@group_user_id).where(:group_id =&gt; @group_id, :user_id =&gt;
        @user_id)
        @newuser.destroy
        redirect_to(:controller =&gt; 'groups', :action =&gt; 'show', :id =&gt; params[:id])
     end
  </code></pre>
  
  <p>but I get this error</p>
  
  <pre><code>ActiveRecord::RecordNotFound in GroupsController#leave
  </code></pre>
  
  <p>Couldn't find <code>GroupUser</code> without an ID</p>
  
  <p>If you need more info about the code please let me know.</p>