'How to register new finder class in spree?
Using spree v4.3, I am trying to register new finder class, but not able to find the right way of doing that, just like we can replace the existing services, serializers etc in app dependencies ( https://dev-docs.spreecommerce.org/customization/dependencies ), how can we register new finder class?
Example:
module Spree
module Employee
class FindCurrent
def initialize(scope: nil)
@scope = scope || Spree::Employee
end
def execute
scope.find_by(id: session[:current_employee_id])
end
end
end
end
Trying to register in initializer:
Spree.dependencies do |dependencies|
# Example:
dependencies.current_employee_finder = 'Spree::Employee::FindCurrent'
end
But when using this in controller like below:
current_employee_finder.new.execute
Getting undefined method - current_employee_finder.
Whats the correct way to define this?
Solution 1:[1]
{selectedValue && (
<div style={{ marginTop: 20, lineHeight: '25px' }}>
<div>
<b>Selected Values: </b>
<span>{
selectedValue.map(item => item.value.length !== 0 ?
<li>{data.filter(data => data.value === item.value[0])[0].label}</li> :
<li>No value selected</li>
)
}</span>
</div>
</div>
)}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yash Sharma |
