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

I don't know why fail. #241

Closed ryanfox1985 closed 8 years ago

ryanfox1985 commented 8 years ago

Hi I added a ActiveRecord class and fails when initializes TableColumnMatrix and I don't know why.

Failures:

  1) Wice::TableColumnMatrix should set default_model_class
     Failure/Error: table.default_model_class = Dummy
     NoMethodError:
       undefined method `model=' for #<ActiveRecord::ConnectionAdapters::Column:0x007f923a61b178>
     # ./lib/wice/table_column_matrix.rb:45:in `block in init_columns_of_table'
     # ./lib/wice/table_column_matrix.rb:45:in `each_value'
     # ./lib/wice/table_column_matrix.rb:45:in `init_columns_of_table'
     # ./lib/wice/table_column_matrix.rb:24:in `default_model_class='
     # ./spec/wice/lib/table_column_matrix_spec.rb:21:in `block (2 levels) in <module:Wice>'
ryanfox1985 commented 8 years ago

well I see is your wrapper xDD.

WiceGridExtentionToActiveRecordColumn

leikind commented 8 years ago

Try running this once before you run anything:

ActiveRecord::ConnectionAdapters::Column.send(:include, ::Wice::WiceGridExtentionToActiveRecordColumn)
ActiveRecord::Base.send(:include, ::Wice::MergeConditions)
leikind commented 8 years ago

btw I have planned a certain modernization of how conditions, order clauses, etc are dealt with. Right now how column filters pass their conditions into the core of the plugin is still hashes or hashes or arrays. I plan to rewrite it and only use ActiveRelation everywhere. This will simplify a lot of things and a lot of code and crazy monkey patching like this one will be just deleted. It will also allow me to modernize the API a bit.