Rails 5.2
datatables
I am following a mini tutorial, on implementing databables with Rails. The table
class BlogDatatable < AjaxDatatablesRails::ActiveRecord
def view_columns
@view_columns ||= {
id: { source: "Blog.id" },
user: { source: "Blog.user_id"}
title: { source: "Blog.title" },
}
end
def data
records.map do |record|
{
id: record.id,
title: record.title,
DT_RowId: record.id,
}
end
end
def get_raw_records
Blog.all
end
end
What I really want to display for the column user, is the user email, but the user email is in the table Users. How do I implement this with datatables, and stil be able to do sorting, based on the email, not the user_id that's in the blogs table?