Thursday, December 13, 2012

Re: [Rails] Filter on multiple select




On Thu, Dec 13, 2012 at 10:23 PM, Lorenz Blackbird <lists@ruby-forum.com> wrote:
Hello,

I have a many-to-many relationship between the model "exams" and the
model "students", in the middle I have the model "registrations".

Students are registered to a "course" (another model) and any exam is
associated to a "course".

I create a view in exams that permit to add the students with multiple
selection:

<%= f.select :student_ids, Student.all.map { |student| [student.name,
student.id] }, { }, { multiple: true }

but this solution show me all students in the db. I wish I had only the
students registered in the same course of exam.

I don't know how filter the array and put it in the multiple selection.

I think you need to add a relationship between a course and a user and use
that relationship to figure out that list of student choices eligible for the exam.
 

Any suggestion?

Thanks to all.

--
Posted via http://www.ruby-forum.com/.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate