I have TestResource with `field :records, as: :has...
# avo-2
e
I have TestResource with
field :records, as: :has_many
. So, in TestResource
:show
I can see index of
records
. I also have RecordResource with custom standalone action. If i'm calling this action from TestResource
:show
, I can only get instance of RecordResource without any associations. But I want to access model instance of TestResource. Is it possible?
l
you can find it yourself
you have access to
params
Copy code
ruby
TestModel.find params[:id]
e
Yes, but params doesn't contain any TestResource information
l
or throught he inverse association
model.test
model is the model for
RecordResource
e
It's standalone action, so it's not linked to RecordResource model
l
hmm. what does the
params
object look like?
can you paste it here?
e
Copy code
<ActionController::Parameters {“authenticity_token”=>“abc123", “fields”=>{“avo_resource_ids”=>“”, “avo_selected_query”=>“”, “custom_field_test”=>“”}, “button”=>“”, “controller”=>“avo/actions”, “action”=>“handle”, “resource_name”=>“records”, “action_id”=>“custom_action”} permitted: false>
I want to get something like test_id (model id of currently opened TestResource) Maybe somehow put it inside customs actions field
l
try
Avo::App.request.referer
you should get the referrer path and extract the id from that
e
Wanted to do something like that, but didn't know how to access current request. Thank you! I also found that
action
accepts arguments. Idk how they are used, but maybe it's possible to pass value here to get them inside
handle
?
the arguments are passed from the resource file
e
Oh, got it. Thank you!