Help, I'm trying to pass a course_id from a collection_select and
can't figure out how to do it.

If I hard-code my method:

def move_stu
  Enrollment.update_all(["course_id = ?", "12" ], :student_id => params
[:student_ids])

  ##
end

It works perfectly. The enrollment updates the student's course_id to
12.

Instead of hard-coding it, I'd like users to be able to select the
course they want to move the student to. My collection_select looks
like this (and I don't get any errors):

<%= collection_select(:student, :course_id,
current_user.courses, :id, :name, :include_blank => true) %>

BUT I haven't been able to pass :id to the move_stu method. I've tried
this:

def move_stu
  Enrollment.update_all(["course_id = ?", id ], :student_id => params
[:student_ids])

  ##
end

but all that passes in is a random 8 digit id from ??? (not the :id
from the collection_select)

Any ideas??? thank you in advance!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to