lemon-wall-20836
01/26/2022, 6:26 AMcolossal-arm-85272
01/26/2022, 3:36 PMimportant-terabyte-39911
01/26/2022, 10:55 PMOrganizer
and Event
, so one event could have many organizers and one organizer can have many events, right?
What I want to accomplish is to create a field in the Event
resource so I can pick already existing Organizer
in my database.
Is that something I can do with Avo out of the box ? or do I need to create my own custom field ?lemon-wall-20836
01/27/2022, 6:18 AMlemon-wall-20836
01/27/2022, 6:19 AMlemon-wall-20836
01/27/2022, 6:19 AMlemon-wall-20836
01/27/2022, 6:19 AMlemon-wall-20836
01/27/2022, 6:19 AMlemon-wall-20836
01/27/2022, 6:20 AMlemon-wall-20836
01/27/2022, 6:20 AMimportant-terabyte-39911
01/27/2022, 2:28 PMquaint-pencil-2979
01/28/2022, 7:05 PMquaint-pencil-2979
01/28/2022, 7:06 PMruby
class ResetPassword < Avo::BaseAction
self.name = 'Resetar senha'
field :new_password, as: :text, default: '1234', name: 'Nova senha'
def handle(models:, fields:)
fail 'Senha não pode ser vazia' if fields["new_password"].blank?
begin
models.each do |model|
model.update!(password: fields["new_password"])
end
succeed 'As senhas foram alteradas com sucesso.'
rescue => e
fail "Error ao alterar senhas: #{e.message}"
end
end
end
When i try to execute the action:
ArgumentError (unknown keywords: :current_user, :resource):
app/avo/actions/toggle_active.rb:6:in `handle'quaint-pencil-2979
01/28/2022, 7:15 PMquaint-pencil-2979
01/28/2022, 7:15 PMquaint-pencil-2979
01/28/2022, 7:36 PMlemon-wall-20836
01/31/2022, 9:24 AMlemon-wall-20836
01/31/2022, 9:26 AMlemon-wall-20836
01/31/2022, 9:28 AMlemon-wall-20836
01/31/2022, 9:39 AMimportant-terabyte-39911
02/02/2022, 11:32 PMconfig.raise_error_on_missing_policy = true
but I'm not getting any exception, I already installed pundit and I only have the ApplicationPolicy
so I think I should be getting exceptions on all of my resources, but that's not the case, what am I doing wrong ?chilly-xylophone-87449
02/03/2022, 3:39 AMlemon-wall-20836
02/03/2022, 6:30 AMlemon-wall-20836
02/03/2022, 6:30 AMlemon-wall-20836
02/03/2022, 6:30 AMcurrent_user_method
in your initializer?lemon-wall-20836
02/03/2022, 6:30 AMconfig.current_user_method = :current_user
in config/initializers/avo.rb
lemon-wall-20836
02/03/2022, 6:31 AMlemon-wall-20836
02/03/2022, 6:32 AMraise_error_on_missing_policy
is working if the current user method is declaredlemon-wall-20836
02/03/2022, 6:34 AMcurrent_user_method
is missing) we'll improve the docs to better surface the informationlemon-wall-20836
02/03/2022, 6:38 AMfriendly_id
should be working. Have you applied a custom find scope to your resource?
Here's a link to the docs with an example on friendly_id
https://docs.avohq.io/1.0/customization.html#custom-find-scope
if that doesn't solve it, can you shoot us up with a ticket and some sample code (resource scope & model set-up for friendly_id
) on https://avo.cool/issues ? It's easier to read the code and collaborate.
Thank you!