Created
December 11, 2020 16:45
-
-
Save leastbad/b16f61929151a7d7a5de6abcef3905ea to your computer and use it in GitHub Desktop.
TenantFilterReflex refactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TenantFilterReflex < ApplicationReflex | |
def filter_property | |
find_tenant_filter(element).update_attribute :property_id, element.value | |
end | |
def filter_unit | |
find_tenant_filter(element).update_attribute :unit_id, element.value | |
end | |
def fuzzy_name_search | |
find_tenant_filter(element).update_attribute :tenant_name_search, element.value | |
end | |
def fuzzy_email_search | |
find_tenant_filter(element).update_attribute :tenant_email_search, element.value | |
end | |
private | |
def find_tenant_filter(element) | |
@tenant_filter = TenantFilter.find(element.dataset['tenant-filter-id']) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TenantFilterReflex < ApplicationReflex | |
def filter | |
@tenant_filter = TenantFilter | |
.find(element.dataset['tenant-filter-id']) | |
.update_attribute element.dataset['filter'].to_sym, element.value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment