leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Joined Tables - ActiveRecord::StatementInvalid - No such Column #193

Closed patricklindsay closed 9 years ago

patricklindsay commented 9 years ago

I want to list all Worksheets and have the ability to filter/order/sort by the name linked to a worksheet through a User object. I am getting a ActiveRecord::StatementInvalid stack trace. App is on Rails 4.1.6

# Error when trying to filter by associated object attribute
SQLite3::SQLException: no such column: users.name: SELECT COUNT(*) FROM "worksheets"  WHERE ((   users.name LIKE '%foo%'))
# User Model
belongs_to :worksheet
# Worksheet Model
has_one :user
# Controller
initialize_grid(Worksheet, include:  :user)
# View
  g.column name: 'Name', attribute: 'name', model: 'User' do |sheet|
    sheet.user.name if sheet.user
  end

I've followed the README and examples and can't seem to see what I am doing wrong?

awanosik commented 9 years ago

I'm having the same issue - it seems as though the joins aren't being added to the query - this is particularly odd as I just used this same functionality for another project a few weeks ago with no issue.

leikind commented 9 years ago

what WIceGrid version is it?

awanosik commented 9 years ago

I'm currently using 3.4.10.

awanosik commented 9 years ago

@leikind

I originally used 3.4.2 as per the READ.ME, then updated the gem later, but forgot to restart my rails server -- I'm assuming @patricklindsay's issue the same. I think this is related to https://github.com/leikind/wice_grid/issues/164 as it was failing on the SQL count statement

leikind commented 9 years ago

@awanosik so it is working with 3.4.10?

leikind commented 9 years ago

@awanosik correct, 3.4.7 is where this thing was fixed

patricklindsay commented 9 years ago

Thanks for the fast reply. Yes I was running 3.4.2, I've now upgraded to 3.4.10 and it's working. Great gem @leikind :+1:
Now to fix those icons... ;)