p8 / table_builder

Rails builder for creating tables and calendars inspired by ActionView's FormBuilder.
186 stars 77 forks source link

TableBuilder expects an Array or ActiveRecord::NamedScope::Scope but found a Array #5

Open dza2000 opened 13 years ago

dza2000 commented 13 years ago

So, as you can read, TableBuilder is throwing an error because it expected an Array, but found an... Array. Not sure why this is throwing an exception. Any wisdom would be appreciated.

MDaubs commented 13 years ago

I'm willing to bet you are using Rails 3 and Arel, yes? If that's the case you are probably sending it an ActiveRecord::Relation. Adding a .all to the end of our query should fix the problem. Example:

# Do this
@widgets = Widget.where(:for_sale => true).all
# Instead of this
@widgets = Widget.where(:for_sale => true)

table_builder should probably be updated to support passing in a ActiveRecord::Relation.