Permalink
Browse files

Bugfix filters when table not exists

  • Loading branch information...
1 parent aad0bd5 commit 4c1a9ca769251d8b2ca814aab985fd3ee6321d50 @bogdan committed Sep 27, 2012
Showing with 9 additions and 8 deletions.
  1. +7 −7 lib/datagrid/filters.rb
  2. +2 −1 spec/datagrid/filters_spec.rb
@@ -67,13 +67,13 @@ def filter(attribute, *args, &block)
protected
def default_filter(attribute)
check_scope_defined!("Scope should be defined before filters")
- if !driver.has_column?(scope, attribute) && driver.to_scope(scope).respond_to?(attribute)
- lambda do |value, scope, grid|
- grid.driver.to_scope(scope).send(attribute, value)
- end
- else
- lambda do |value, scope, grid|
- grid.driver.where(scope, attribute => value)
+
+ lambda do |value, scope, grid|
+ driver = grid.driver
+ if !driver.has_column?(scope, attribute) && driver.to_scope(scope).respond_to?(attribute)
+ driver.to_scope(scope).send(attribute, value)
+ else
+ driver.where(scope, attribute => value)
end
end
end
@@ -51,8 +51,9 @@ class TheReport
scope {ModelWithoutTable}
filter(:name)
+ filter(:limit)
end
- TheReport.new(:name => 'hello')
+ TheReport.new(:name => 'hello').should_not be_nil
end
it "should support inheritence" do

0 comments on commit 4c1a9ca

Please sign in to comment.