I am running the following active record query
Keyword.joins(:questions, :users, :associations).select("questions.*, keywords.keyword").where(users: {id: @user.id})
and presenting the results using wice_grid using the following code -
<%= grid(@questions, show_filters: :false) do |g|
g.column name: 'ID', attribute: 'id', filter: false
g.column name: 'Question', model:'Question', attribute: 'question'
g.column name: 'Keyword', model:'Keyword', attribute: 'keyword'
end %>
The question attribute gets populated fine, but the keyword attribute shows up in hexadecimal value such as #< Keyword:0x00000104eb00a0>. Any idea why? Any help is highly appreciated.
From https://github.com/leikind/wice_grid#queries-with-join-tables:
Please note that the blockless definition of the column only works with columns from the main table and it won’t work with columns with :model
<%= grid(@questions, show_filters: :false) do |g|
g.column name: 'ID', attribute: 'id', filter: false
g.column name: 'Question', model:'Question', attribute: 'question'
g.column name: 'Keyword', model:'Keyword', attribute: 'keyword' do |question|
question.keyword.keyword
end
end %>