https://avo.cool logo
Join Discord
Powered by
# general
  • l

    lemon-wall-20836

    02/14/2025, 9:14 AM
    message has been deleted
  • l

    loud-jewelry-99127

    02/14/2025, 10:25 AM
    message has been deleted
  • l

    loud-jewelry-99127

    02/14/2025, 10:25 AM
    message has been deleted
  • m

    millions-exabyte-27721

    02/20/2025, 9:55 AM
    Hey all, I have a quick question regarding
    has_many
    associations pointing to an STI model (I've read https://docs.avohq.io/3.0/associations.html): I understand that using
    link_to_child_resource
    I can opt into linking to a child resource from the association's table in the parent resource. However, is there a built-in/simple way to choose which child resource to create?
  • m

    millions-exabyte-27721

    02/20/2025, 9:56 AM
    or is the best approach to use a
    field :type, as: :select, ...
    ?
  • l

    loud-jewelry-99127

    02/20/2025, 9:58 AM
    The belongs to field have the
    polymophic_as
    and
    types
    options which will automatically generate a :type field https://docs.avohq.io/3.0/associations/belongs_to.html#polymorphic_as
  • m

    millions-exabyte-27721

    02/20/2025, 10:04 AM
    hmmm I'm not sure if this applies? I'm not talking about a polymorphic association (as in, a child that could be attached to many possible parents), but the other way round - the parent (a
    Survey
    ) can have specific different children (
    FreeformSurveyQuestion
    ,
    MultipleChoiceSurveyQuestion
    , ...)
  • l

    loud-jewelry-99127

    02/20/2025, 10:05 AM
    And the
    FreeformSurveyQuestion
    ,
    MultipleChoiceSurveyQuestion
    , ... are all represented by 1 resource?
  • m

    millions-exabyte-27721

    02/20/2025, 10:05 AM
    no, each has their own resource
  • they just have the same parent model (
    m

    millions-exabyte-27721

    02/20/2025, 10:05 AM
    they just have the same parent model (
    SurveyQuestion
    )
    l
    a
    • 3
    • 77
  • I'm hitting a wall with a HABTM relation
    m

    millions-exabyte-27721

    03/03/2025, 12:30 PM
    I'm hitting a wall with a HABTM relation. Granted, it's a pretty "complicated" one because it's between namespaced models. But Avo raises an error that makes little sense to me: > Avo relies on the 'inverse_of' option to establish the inverse association and perform some specific logic. > Please configure the 'inverse_of' option for the 'has_and_belongs_to_many :surveys_question_options' association in the 'Surveys::Response' model. but it's there:
    Copy code
    rb
    class Surveys::Response < ApplicationRecord
      belongs_to :user
      belongs_to :surveys_question, class_name: "Surveys::Question"
    
      has_and_belongs_to_many :surveys_question_options,
                              inverse_of: :surveys_response,
                              class_name: "Surveys::QuestionOption",
                              foreign_key: :surveys_response_id,
                              association_foreign_key: :surveys_question_option_id
    end
    Copy code
    rb
    class Avo::Resources::SurveysSingleChoiceResponse < Avo::BaseResource
      # self.includes = []
      # self.attachments = []
      self.model_class = ::Surveys::SingleChoiceResponse
      # self.search = {
      #   query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) }
      # }
    
      def fields
        field :id, as: :id
        field :user, as: :belongs_to, readonly: true
        field :surveys_question, as: :belongs_to, readonly: true
        field :surveys_question_options, as: :has_and_belongs_to_many, readonly: true
      end
    end
    l
    • 2
    • 45
  • l

    loud-jewelry-99127

    03/12/2025, 4:15 PM
    message has been deleted
  • good morning friends, a short question
    m

    millions-exabyte-27721

    03/14/2025, 8:12 AM
    good morning friends, a short question regarding attaching records in a
    has_many ... through:
    dialog: How can I avoid duplicates showing up in the select box? I have users I want to attach to segments, but of course it doesn't make sense to attach the same user to a segment twice I handle this on the database level using a unique index, but of course it'd be nice if those already connected users wouldn't show up in the select box at all...
    l
    • 2
    • 16
  • m

    millions-exabyte-27721

    03/14/2025, 8:12 AM
    ah, using
    attach_scope
    probably?
  • l

    loud-jewelry-99127

    03/25/2025, 9:56 AM
    message has been deleted
  • c

    clever-iron-16361

    03/25/2025, 9:57 AM
    hello! πŸ™‚
  • l

    loud-jewelry-99127

    03/25/2025, 9:57 AM
    Hi there, welcome!
  • Avo - Ruby on Rails Admin Panel Framewor...
    m

    millions-exabyte-27721

    03/26/2025, 8:18 AM
    I know that I can use
    attach_fields
    (https://docs.avohq.io/3.0/associations/has_many.html#attach_fields) to display extra fields when attaching a record of a
    has_many through:
    . In my case it's a simple checkbox https://cdn.discordapp.com/attachments/740892037640880180/1354368997935546438/image.png?ex=67e509ec&is=67e3b86c&hm=32d6631e8e0cc10af8233c7af865afc4ed22aa2cb2f17f4c9b0eac398785e8b8&
    l
    l
    • 3
    • 27
  • l

    lemon-wall-20836

    03/28/2025, 2:38 AM
    message has been deleted
  • l

    lemon-wall-20836

    03/28/2025, 2:38 AM
    message has been deleted
  • batch CSV processing
    m

    millions-exabyte-27721

    03/31/2025, 9:13 AM
    I think I've seen a video or guide article for batch processing CSV data but can't seem to find it πŸ€”
    l
    • 2
    • 31
  • Hey beautiful people! I upgraded to avo
    e

    early-leather-2501

    03/31/2025, 10:25 AM
    Hey beautiful people! I upgraded to avo 3.18.2 and got the following error:
    Copy code
    12:09:19 web.1     | 2025-03-31 12:09:19 INFO   Rendered layout /Users/michael/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/avo-3.18.2/app/views/layouts/avo/application.html.erb (Duration: 153.3ms | GC: 0.0ms)
    12:09:19 web.1     | 2025-03-31 12:09:19 INFO Completed 500 Internal Server Error in 649ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
    12:09:19 web.1     |
    12:09:19 web.1     |
    12:09:19 web.1     | 2025-03-31 12:09:19 ERROR
    
    12:09:19 web.1     | ActionView::Template::Error (undefined method 'avo_dashboards' for an instance of #<Class:0x000000013ca379f0>)
    12:09:19 web.1     | Caused by: NoMethodError (undefined method 'avo_dashboards' for an instance of #<Class:0x000000013ca379f0>)
    12:09:19 web.1     |
    12:09:19 web.1     | Information for: ActionView::Template::Error (undefined method 'avo_dashboards' for an instance of #<Class:0x000000013ca379f0>):
    12:09:19 web.1     |     32:         <%= render partial: "avo/partials/navbar", locals: { resource: @resource } %>
    12:09:19 web.1     |     33:         <div data-sidebar-target="mainArea" class="content-area flex-1 flex pt-16 relative <%= "sidebar-open" if @sidebar_open %>">
    12:09:19 web.1     |     34:           <div class="hidden lg:flex">
    12:09:19 web.1     |     35:             <%= render Avo::SidebarComponent.new sidebar_open: @sidebar_open %>
    12:09:19 web.1     |     36:           </div>
    12:09:19 web.1     |     37:           <div class="flex lg:hidden">
    12:09:19 web.1     |     38:             <%= render Avo::SidebarComponent.new sidebar_open: false, for_mobile: true %>
    12:09:19 web.1     |
    12:09:19 web.1     | railties (8.0.2) lib/rails/engine/lazy_route_set.rb:99:in 'method_missing'
    12:09:19 web.1     | avo-menu (3.18.2) app/components/avo/sidebar/item_switcher_component.html.erb:8:in 'Avo::Sidebar::ItemSwitcherComponent#call'
    12:09:19 web.1     | view_component (3.21.0) lib/view_component/compiler.rb:98
    l
    • 2
    • 6
  • l

    loud-jewelry-99127

    04/02/2025, 6:56 AM
    message has been deleted
  • Nice work on nested records, team! Can’t
    d

    dry-rainbow-18454

    04/02/2025, 1:07 PM
    Nice work on nested records, team! Can’t wait to check it out. πŸ™Œ
    l
    l
    • 3
    • 2
  • c

    colossal-ambulance-71638

    04/02/2025, 7:23 PM
    > We want your feedback and ideas. Let's think about what a complete Rails app would need and make that happen! I'm still waiting on a good WYSIWYG editor. I tried
    rhino
    but it's not even close to what TinyMCE gives out of the box.
  • I think I'm hitting an edge case (again
    m

    millions-exabyte-27721

    04/07/2025, 9:47 AM
    I think I'm hitting an edge case (again), this time around polymorphic relations. I've got this model, and I want to display the
    recipients
    in a list:
    Copy code
    rb
    class Mailing < ApplicationRecord
      belongs_to :mailable, polymorphic: true
    
      delegate :recipients, to: :mailable
    end
    and an example of a `mailable`:
    Copy code
    rb
    class Event < ApplicationRecord
      has_many :recipients
      has_many :mailings, as: :mailable
    end
    The
    delegate
    is necessary, because you can't specify a
    has_many through:
    on a polymorphic association:
    Copy code
    rb
      has_many :recipients, through: :mailable
    
      # => Cannot have a has_many :through association 'Mailing#recipients' which goes through the polymorphic association 'Mailing#mailable'. (ActiveRecord::HasManyThroughAssociationPolymorphicThroughError)
    I tried to solve this with an
    Array
    field, but failed because it needs an
    ArrayResource
    to back it. Is there any other way to achieve this?
    l
    • 2
    • 40
  • Hey folks, I was trying `nested` feature
    f

    flat-television-5571

    04/07/2025, 10:56 AM
    Hey folks, I was trying
    nested
    feature and was getting `undefined method `klass for nil from this method def model @model ||= @parent_model_class.reflections[@field.name.downcase].klass end, from
    avo-advanced (3.19.1) app/components/avo/advanced/nested/field_component.rb:29
    , I noticed that I was getting
    "purchase order items"
    from "@field.name.downcase" instead of purchase_order_items. I think this only works if we have model name without underscore.
    l
    • 2
    • 14
  • hey guys - question unrelated to avo:
    n

    narrow-electrician-89982

    04/14/2025, 6:41 AM
    hey guys - question unrelated to avo: have any one ever built a user calendar with repeating events ? if yes, how did you handle occurencies ? how did you handle updating an event vs updating the parent event's occurences ? what happens if you have invited someone to the event and then deleted it ? should you send him to the next event or what ? thanks πŸ™
    l
    f
    • 3
    • 12
  • boolean_group computed options
    m

    millions-exabyte-27721

    04/22/2025, 2:45 PM
    I think I have found a bug in the
    boolean_group
    field type, specifically computed options: I found that if I try to update a record from computed options derived from the
    record
    it does not work. I chased that down to the fact that when I add a breakpoint in the field's computed options lambda and issue a PUT, there,
    record
    is nil:
    Copy code
    rb
        field :event_roles,
              as: :boolean_group,
              options: -> do
          binding.irb
          record&.event&.roles || {}
        end
    =>
    Copy code
    irb(#<Avo::ExecutionContext:0x000...):007> record
    => nil
    note that this is not the case when it's called regularly from the
    edit
    view. it also works as expected with options supplied as a regular hash
    l
    • 2
    • 10
  • l

    lemon-wall-20836

    05/07/2025, 4:24 PM
    message has been deleted