Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3672258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:35:13+00:00 2026-05-19T02:35:13+00:00

I have this in courses.html.erb under app/views/students <% if @student.courses.count < Course.count then%> <%

  • 0

I have this in courses.html.erb under app/views/students

<% if @student.courses.count < Course.count then%>
  <% form_tag(course_add_student_path(@student)) do%>
  <%= select_tag(:course, options_from_collection_for_select(@student.unenrolled_courses, :id, :name))%>
  <%= submit_tag 'Enroll'%>
  <%end%>
  <%else%>
  <p><%=h @student.name%> is enrolled in every course. </p>
 <%end%>

I have this in my students_controller.rb under app/controllers:

  def course_add
    @student = Student.find(params[:id])
    @course = Course.find(params[:course])

    unless @student.enrolled_in?(@course)
      @student.coursess << @course
      flash[:notice] = 'course added'
    else
      flash[:error] = 'course already enrolled'
    end
    redirect_to :action => courses, :id => @student
  end

And in my routes.rb, I have:

  resources :students, :has_many => [:awards], :member => {:courses => :get, :course_add => :post, :course_remove => :post}

However, I am getting this error:

undefined method `course_add_student_path' for #<#<Class:0x105321d78>:0x1053200e0>

What am I missing here?

Rake routes output:

          students GET    /students(.:format)                             {:action=>"index", :controller=>"students"}
                   POST   /students(.:format)                             {:action=>"create", :controller=>"students"}
       new_student GET    /students/new(.:format)                         {:action=>"new", :controller=>"students"}
      edit_student GET    /students/:id/edit(.:format)                    {:action=>"edit", :controller=>"students"}
           student GET    /students/:id(.:format)                         {:action=>"show", :controller=>"students"}
                   PUT    /students/:id(.:format)                         {:action=>"update", :controller=>"students"}
                   DELETE /students/:id(.:format)                         {:action=>"destroy", :controller=>"students"}
           courses GET    /courses(.:format)                              {:action=>"index", :controller=>"courses"}
                   POST   /courses(.:format)                              {:action=>"create", :controller=>"courses"}
        new_course GET    /courses/new(.:format)                          {:action=>"new", :controller=>"courses"}
       edit_course GET    /courses/:id/edit(.:format)                     {:action=>"edit", :controller=>"courses"}
            course GET    /courses/:id(.:format)                          {:action=>"show", :controller=>"courses"}
                   PUT    /courses/:id(.:format)                          {:action=>"update", :controller=>"courses"}
                   DELETE /courses/:id(.:format)                          {:action=>"destroy", :controller=>"courses"}
    student_awards GET    /students/:student_id/awards(.:format)          {:action=>"index", :controller=>"awards"}
                   POST   /students/:student_id/awards(.:format)          {:action=>"create", :controller=>"awards"}
 new_student_award GET    /students/:student_id/awards/new(.:format)      {:action=>"new", :controller=>"awards"}
edit_student_award GET    /students/:student_id/awards/:id/edit(.:format) {:action=>"edit", :controller=>"awards"}
     student_award GET    /students/:student_id/awards/:id(.:format)      {:action=>"show", :controller=>"awards"}
                   PUT    /students/:student_id/awards/:id(.:format)      {:action=>"update", :controller=>"awards"}
                   DELETE /students/:student_id/awards/:id(.:format)      {:action=>"destroy", :controller=>"awards"}
   courses_student GET    /students/:id/courses(.:format)                 {:action=>"courses", :controller=>"students"}
                   GET    /students(.:format)                             {:action=>"index", :controller=>"students"}
                   POST   /students(.:format)                             {:action=>"create", :controller=>"students"}
                   GET    /students/new(.:format)                         {:action=>"new", :controller=>"students"}
                   GET    /students/:id/edit(.:format)                    {:action=>"edit", :controller=>"students"}
                   GET    /students/:id(.:format)                         {:action=>"show", :controller=>"students"}
                   PUT    /students/:id(.:format)                         {:action=>"update", :controller=>"students"}
                   DELETE /students/:id(.:format)                         {:action=>"destroy", :controller=>"students"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:35:13+00:00Added an answer on May 19, 2026 at 2:35 am

    Your routes syntax is wrong. Try this instead:

    resources :students do
      resources :awards
      member do
        get "courses"
        post "course_add"
        post "course_remove"
      end
    end
    
    • http://guides.rubyonrails.org/routing.html#nested-resources
    • http://guides.rubyonrails.org/routing.html#adding-more-restful-actions
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
Of course most languages have library functions for this, but suppose I want to
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have a form with the following HTML below: <form id=course_edit_form name=course_form action=/courses/save method=post>
I have this html page which globally exists of div , section , and
I have a student that has many courses. In the student#update action and form,
i have a course table and a course due dates table like this course_id
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.