If you override your to param of your
# avo-2
m
If you override your to_param of your model, how do you have to update your model_resource so that way you can show/edit/destroy using that new field?
l
You should use the
find_record_method
yeah. the search isn't great in the docs. if you know someone that has experience with algolia search, please send them our way 🙏
but I need to update the docs
check this example
m
I'm not using friendlyId self.find_record_method = ->(model_class:, id:, params:) { !id.is_a?(Array) && id.to_i == 0 ? model_class.find_by(youtube_id: id) : model_class.find(id) } I have a youtube_id on a video resource.
Copy code
ruby
def to_param
  youtube_id
end
l
perfect!
m
The show view works
not the edit
l
ok. can you please open an issue?
but that's something else
do you have a
VideoPolicy
?
you should then have a
def resolve
method on that policy
m
l
yeah, but you have to do it 🙂
it's not an Avo issue 🙂
add this inside the
ApplicationPolicy
Copy code
ruby
class ApplicationPolicy
  class Scope
    attr_reader :user, :scope

    def initialize(user, scope)
      @user = user
      @scope = scope
    end

    def resolve
      scope.all
    end
  end
end
m
l
post it on the issue please
these convos get lost
m
done! 🙂
l
let's continue the conversation there. I asked a question
m
Thank you for the help!