rawnet / rawnet-admin

An inheritable admin interface for Ruby on Rails apps
MIT License
0 stars 2 forks source link

ActiveRecord class no longer usable for current scope #16

Closed jonathansayer closed 8 years ago

jonathansayer commented 8 years ago

The apply_scopes_if_necessary method will in some instances return the model itself - it seems in the latest versions of rails you can't call .each on the model without first creating a scope.

Solution would be to just call all, however in older versions of Rails this will return an array, which isn't expected. where(nil) might be more backwards compatible for now.

    def apply_scopes_if_available(association)
      respond_to?(:apply_scopes, true) ? apply_scopes(association.all) : association.all
    end