keyan.r keyan.r - 1 year ago 94
Ruby Question

Implementing .each in Wicegrid (Ruby on Rails)

I have the following column in my Wicegrid table, which iterates through the advisors of a student and lists them in the Wicegrid:

g.column name: 'Student Advisor' do |user|
if user.advisors
user.advisors.each do |advisor|

Wicegrid doesn't allow arrays to be returned inside their columns or at least that is what I understood from the error below:

"When WiceGrid column block returns an array its second element is expected to be a hash containing HTML attributes for the tag."

Is there another way to have the list of advisors in the table?

Answer Source

If I understood the requirements properly, the following will return a list of advisors, if exists, concatenated with commas:

g.column name: 'Student Advisor' do |user|', ') if user.advisors