I'm trying to do a filter with a where clause and indicating the table.
Currently I'm using this, that only works if it's the exact same username:
@diagnostics = Diagnostic.scoped
@diagnostics = @diagnostics.includes(:user).where(tbl_users: { username: "#{params[:search]}" }) if params[:search_by] == 'by_user'
I'm trying to do a search where it can be use with a like, and its not working:
@diagnostics = Diagnostic.scoped
@diagnostics = @diagnostics.includes(:user).where(tbl_users: { username: "%#{params[:search]}%" }) if params[:search_by] == 'by_user'
Any solutions ?
Thanks.