https://avo.cool logo
Join Discord
Powered by
# avo-2
  • q

    quaint-pencil-2979

    01/21/2022, 6:52 PM
    I know is a bad name, but i cant change this right now in the system, is huge
  • l

    lemon-wall-20836

    01/21/2022, 6:52 PM
    Is it a new app? Can you change it to MediaItem? Rails recommends doing that in the docs
  • l

    lemon-wall-20836

    01/21/2022, 6:52 PM
    Mm
  • l

    lemon-wall-20836

    01/21/2022, 6:52 PM
    Got it
  • l

    lemon-wall-20836

    01/21/2022, 6:53 PM
    Can you create am issue please?
  • q

    quaint-pencil-2979

    01/21/2022, 6:53 PM
    Yes of course
  • l

    lemon-wall-20836

    01/21/2022, 6:53 PM
    With some reporducible scenrsio please
  • l

    lemon-wall-20836

    01/21/2022, 6:53 PM
    Thank you!
  • q

    quaint-pencil-2979

    01/21/2022, 6:53 PM
    Ok, a will try to reproduce with fish, is the classic for this problem
  • l

    lemon-wall-20836

    01/21/2022, 6:54 PM
    If it’s the same, then, shouldn’t it be fixed?
  • l

    lemon-wall-20836

    01/21/2022, 6:55 PM
    We didn’t introduce a fix case for fish
  • l

    lemon-wall-20836

    01/21/2022, 6:58 PM
    I’ll have a look at the issue
  • q

    quaint-pencil-2979

    01/21/2022, 7:04 PM
    We fix routes, but not search
  • q

    quaint-pencil-2979

    01/21/2022, 7:04 PM
    Is happens to fish model too, i will create the issue right now
  • l

    lemon-wall-20836

    01/21/2022, 7:08 PM
    Got it
  • l

    lemon-wall-20836

    01/21/2022, 7:08 PM
    Will try it tomorrow
  • l

    lemon-wall-20836

    01/21/2022, 7:08 PM
    Thanks for getting in touch with us
  • q

    quaint-pencil-2979

    01/21/2022, 7:12 PM
    Thank you!! https://github.com/avo-hq/avo/issues/600
  • b

    brief-king-35906

    01/23/2022, 4:39 PM
    does a proc passed to
    default
    when declaring a field have access to the user? i've got a
    belongs_to
    association, and generally this will be a single record. i'd like to default to that record if the user only has a single possible record
  • l

    lemon-wall-20836

    01/23/2022, 9:42 PM
    Hey @brief-king-35906. Makes sense. Unfortunately not roght now. We can add support for that next week.
  • l

    lemon-wall-20836

    01/23/2022, 9:42 PM
    What else do you think you’d like to have access to?
  • l

    lemon-wall-20836

    01/23/2022, 9:52 PM
    Actually, you might be able to reference ‘Avo::App.context’ in that block
  • b

    brief-king-35906

    01/24/2022, 8:29 AM
    great! i’ll give it a try
  • b

    brief-king-35906

    01/24/2022, 8:31 AM
    probably the resource, the model and the user? should give me enough to work with. for an association like
    belongs_to
    it’d probably be good to have the scoped collection as well (mine is through a pundit policy for example)
  • b

    brief-king-35906

    01/24/2022, 9:05 AM
    i can get
    Avo::App.view_context
  • b

    brief-king-35906

    01/24/2022, 9:06 AM
    for now i've gone with:
    Copy code
    ruby
      field :system, as: :belongs_to, required: true, default: -> do
        scope = authorization.apply_policy(System.all)
        if scope.one?
          scope.first.id
        else
          nil
        end
      end
  • b

    brief-king-35906

    01/24/2022, 9:07 AM
    which is fine in my context, but for others the
    belongs_to
    association could have a scope
  • b

    brief-king-35906

    01/24/2022, 9:48 AM
    another question: do you support authorising actions based on the resource? in my app, a
    System
    has many
    Entry
    records. a user should be authorised to interact with an
    Entry
    if they are an admin (
    user.admin?
    ) or they curate the
    System
    that the
    Entry
    belongs to (
    user.curated_systems.include?(entry.system)
    ). an extract of the policy which enforces this:
    Copy code
    ruby
    class EntryPolicy < ApplicationPolicy
      def show?
        user.admin? || entry_curated_by_user?
      end
    
      private
    
      def entry_curated_by_user?
        user.curated_systems.include? record.system
      end
    end
    my records are always set to the class (
    Entry
    ) and as a result cannot determine anything about the instance. it looks like this will always be the case as [
    authorize_action
    ](https://github.com/avo-hq/avo/blob/6c16f808da4176ba8ef6fd97339704db6506efec/app/controllers/avo/application_controller.rb#L110-L116) is expecting
    @model
    to be set, but we call
    set_model
    after
    authorize_action
    in [
    Avo::BaseController
    ](https://github.com/avo-hq/avo/blob/6c16f808da4176ba8ef6fd97339704db6506efec/app/controllers/avo/base_controller.rb#L8-L9)
  • b

    brief-king-35906

    01/24/2022, 10:08 AM
    for now i've added this concern to all my avo controllers https://github.com/exlibrisrpg/exlibris/blob/2008f764a4ef79526cc4820cb9dd50ad332e7be1/app/controllers/concerns/avo/authorizable.rb
  • c

    colossal-arm-85272

    01/25/2022, 9:47 PM
    👋 hey hey! recently updated from 1.17 to 1.18.2 and have run into an issue editing resources that have more than one word in the name (e.g.
    TeamMembership
    ). it appears the put request is nesting the form under
    "teammembership"
    rather than
    "team_membership"
    as the controller expects, resulting in an
    ActionController::ParameterMissing
    in the base controller action. seem like this is reproducible in the demo? https://avodemo.herokuapp.com/avo/resources/team_memberships/49/edit happy to report on GH! just wanted to pop in here before I do ✌️
1...222324...64Latest