Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass the right number of arguments into Rails controller
    primarykey
    data
    text
    <p>I am trying to delete an entry in the interview_participant table via the interviews_participants controller. I've got through a number of issues but am getting stuck on an error: </p> <p>ArgumentError in InterviewsParticipantsController#destroy "wrong number of arguments (0 for 1)"</p> <p>The model for interview_participant is... </p> <pre><code>class InterviewParticipant &lt; ActiveRecord::Base belongs_to :interview belongs_to :participant attr_accessible :interview_id, :participant_id </code></pre> <p>and the destroy method in the interview_participants controller is </p> <pre><code> def destroy @interview_participant = InterviewParticipant.where(:interview_id =&gt; params[:interview_id]).where(:participant_id =&gt; params[:participant_id]) @interview_participant.destroy respond_to do |format| format.html { redirect_to interview_participant_url } format.json { head :no_content } end end </code></pre> <p>I would like to be able to remove a participant from an interview by deleting the row in the interview_participant table through this destroy method. In the "show" view for an interview I am isting the participants and would like a button to remove a participant. In the show view for an interview I have...</p> <pre><code>&lt;p&gt; &lt;b&gt;Participants&lt;/b&gt; &lt;% @interview.participants.each do |participant| %&gt; &lt;dd&gt;&lt;%= participant.name %&gt;&lt;/dd&gt; &lt;dd&gt;&lt;%= button_to( "Remove", { :controller =&gt; "interview_participants", :action =&gt; "destroy", :interview_id =&gt; @interview.id, :participant_id =&gt; participant.id }, :method =&gt; :delete, :confirm =&gt; "Are you sure?" ) %&gt;&lt;/dd&gt; &lt;% end %&gt; &lt;/p&gt; </code></pre> <p>I think I am passing the right arguments becasue my URL is <code>/interview_participants/1?interview_id=3&amp;participant_id=2</code> (when I press the button next to for participant 2 and interview 3). But I get the "wrong number of arguments" error in my browser. I've been looking at this for several hours and would really appreciate any help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload