general URL helper
# general
w
Hey .... is there a URL helper method I can use to link directly to a resource in Avo? Something like:
avo_resource_url(record)
l
Hey @wonderful-oil-45883 ✌️ There is no such method, it might be straight forward to implement when the avo resource model mapping is done 1 to 1. But when the same record have multiple resources what would be the rule to choose the "correct" resource?
w
It's a 1 to 1 mapping between a model and a resource .... Here's my use case: I pass an ActiveRecord model of type
Person
or
Company
into a job ... both models have corresponding Avo resources .... I want to generate a link to the Avo page for the supplied record. Does that make sense?
l
something like this method should work (UNTESTED) :
Copy code
ruby
def avo_resource_url(record)
  avo.send :"resources_#{record.class.name.underscore}_path", record
end
It totally makes sense, what i meant is that would be more complex for us to maintain such a method for 1 to many mapping
w
> is that would be more complex for us to maintain such a method for 1 to many mapping Ah right, I see 🙂 Thanks I'll give that a go 🙏
l
Anytime!