https://avo.cool logo
@Adrian M @Paul Bob and another
# general
t
@lemon-wall-20836 @loud-jewelry-99127 and another question, please when I use Resource tools, how can I declare variable since I don't have access to the controller?
Copy code
<%
  @certificate = @resource.record
  @supplier = @certificate.supplier
  @company_rf = @supplier.company_rf
  @url = Certificates::CalculateLink.call(certificate: @certificate)
  @global_certificate = Certificates::FindGlobalCertificate.call(certificate: @certificate)
%>
I did this but it is a very bad practice and bad smell
l
declare them on the
.rb
file and then use them in the
erb
using
tool.SOMETHING
t
@lemon-wall-20836 sorry but I could not do this... what .rb file? BaseResource or BaseResourceTool? And how can I declare these variables? I did not find it anywhere
https://docs.avohq.io/3.0/resource-tools.html deserves a topic here like Custom variables
l
You can declare them on the tool inicializer
l
you're right!
you should declare them on the
tool_name.rb
file
when you generated the tool
r g avo:resource_tool something
, you got two files.
something.rb
and
something.html.erb
. the
something.rb
file is where you should declare the variables
t
Thank you both!!! ❤️
l
I posted an example on the issue 👆