given student_str
to be 1PI12CS019;1PI10IS034;1PI11ME110
, the easiest way to fetch users with those ids is to split the string first and query using the result.
>> student_str = '1PI12CS019;1PI10IS034;1PI11ME110'
>> ids = student_str.split(';')
>> User.where(id: ids) # should give you a list of users matching the ids in the string
Knowing this, there are actually 2 things I'd like to bring up.
- you'll have an easier life using Rails if you stick to convention so I suggest you use integers as ids instead of those strings.
- instead of saving the ids in a single column, you're better off with creating another table that will associate users and students. Easiest way to do this is via has_and_belongs_to_many. A more complex approach would be to use has_many through. A quick google search for this should give you good results.
Good luck!