Filter on the foreign key id
Hi,
We have 2 models - user and user_transaction. user_transaction belongs to user. We are able to show the user.id(primary key) in the user_transaction table view. But, we are not able to add the user.id in the filter list. Our use case is to filter all the transactions for a user given his user_id.
Can you please see if we are missing anything. Snippet of our code is:
filter [:id, :user_id, transaction_id, :inserted_at, :updated_at]
index do
selectable_column
column :id
column :transaction_id
column :user, label: "user_id", fields: [:id]
column :inserted_at
column :updated_at
actions # display the default actions column
end
end
We can see other fields in the filter list, but user_id is not showing up.
Without digging into the code I believe the problem is that label: "user_id" defines a decorator and not an alias you can code against. Trying using the actual column name of "user" and see if that corrects the problem.
@sreekanthrv has this issue been fixed?