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

    thankful-stone-82785

    11/13/2022, 1:41 PM
    Question about https://docs.avohq.io/2.0/recipes/add-nested-fields-to-forms.html, I have an
    Invoice
    model with
    accepts_nested_attributes_for :line_items
    however, using
    fields_for
    in the resource view and
    extra_params
    in the resource, but updating one of the nested fields creates the line items again instead of updating. Looking at the payload going to Rails it's in this form:
    {"line_items_attributes"=>{"0"=>{"id"=>"159", "description"=>""}
  • t

    thankful-stone-82785

    11/13/2022, 1:43 PM
    seems to be index based instead of ID based
  • v

    victorious-kangaroo-12568

    11/14/2022, 9:57 PM
    Hi avo people!!! is there any way to pass a collection for select fields in actions? eg: I'm trying to select user names in an action, like
    field :users, as: :select, options: User.all.map(&:name)
    but when I destroy some users, this list is never updated. It's possible to pass some query to get this list updated in actions ?
    l
    • 2
    • 7
  • r

    ripe-article-50191

    11/17/2022, 10:42 AM
    Tailwind css code is not rendered in the same way inside AVO or outside
    l
    • 2
    • 21
  • r

    ripe-article-50191

    11/17/2022, 10:44 AM
    When I copy some tailwind css code (for example button group) and paste in a page outside of AVO it looks correct, but when I paste the same code in an AVO tool page, the look is different. How can I solve this? Thanks in advance.
  • m

    mammoth-guitar-49791

    11/22/2022, 11:52 AM
    If I have a column
    aspect_ratio, decimal
    and I have it assigned to a text input on avo. on my model i have
    Copy code
    ruby
      before_save :convert_aspect_ratio
      def convert_aspect_ratio
        self.aspect_ratio = aspect_ratio.to_r.to_f
      end
    Copy code
    ruby
    field :aspect_ratio, as: :text
    What else do I need to do to make sure that the input is applied properly to the model?
    l
    • 2
    • 30
  • l

    lemon-wall-20836

    11/22/2022, 12:13 PM
    If I have a column `aspect ratio
  • s

    straight-mechanic-78430

    11/23/2022, 12:28 PM
    Hi Avo-people ๐Ÿ™‚ do someone know if I can have an action running without a record being selected ? in the index view we need to implement some maintenance actions which will run on resource level thanks a lot
    l
    • 2
    • 5
  • m

    mammoth-guitar-49791

    11/23/2022, 3:08 PM
    @lemon-wall-20836 Do you have any plans to add a date/calendar filter to Avo anytime soon?
    l
    • 2
    • 1
  • m

    mammoth-guitar-49791

    11/23/2022, 4:12 PM
    Is there a way to add a validation to a text_field_filter in avo?
    Copy code
    ruby
    class PurchasedBeforeFilter < Avo::Filters::TextFilter
      self.name = "Purchase date before filter"
      self.button_label = "Apply"
      self.empty_message = "YYYY-MM-DD"
    
      def apply(request, query, value)
        query.purchased_before(value)
      end
    end
    l
    • 2
    • 8
  • s

    straight-mechanic-78430

    11/24/2022, 9:52 AM
    Hi @lemon-wall-20836 I just came across a problem while using actions : we have defined to be used set_primary action
    Copy code
    ruby
       class SetToPrimaryAction < ::ApplicationBaseAction
        self.name = "SetToPrimary"
    
        self.visible = lambda do
          begin
            return false unless view == :show || view == :index
    
            current_user.may?(:set_to_primary, resource.model)
          end
        end
    the resource we receive in the visible block is always the parent resource . Regardless if the action is involved in a regular show view or in an index view for the has_many association. We are expecting to get the resource of the has_many association . can u please confirm the problem/bug ?
    l
    l
    • 3
    • 11
  • l

    lemon-wall-20836

    11/24/2022, 10:55 AM
    Hi adrianthedev4617
  • m

    mammoth-guitar-49791

    11/24/2022, 2:08 PM
    I'm trying to write a csv output for associated records without the boolean checkmarks (exports the specified fields). When I try to access the fields attribute at the debugger statement, I get an empty array.
    Copy code
    ruby
    class ExportCsv < Avo::BaseAction
      self.name = "Export CSV"
      self.may_download_file = true
    
      field :id
      field :created_at
      field :email do |model|
        model.user.email
      end
      field :first_name do |model|
        model.user.first_name
      end
      field :last_name do |model|
        model.user.last_name
      end
      field :theme_name do |model|
        model.theme.name
      end
    
      def handle(models:, resource:, fields:, **)
        debugger
    
        return error "No record selected" if models.blank?
        file = CSV.generate(headers: true) do |csv|
          csv << columns
    
          models.each do |record|
            csv << columns.map do |attr|
              record.send(attr)
            end
          end
        end
    
        download file, "#{resource.plural_name}_#{Time.zone.now}.csv"
      end
    end
    l
    • 2
    • 2
  • r

    ripe-article-50191

    11/25/2022, 8:06 AM
    Problems using custom index query
    l
    • 2
    • 5
  • r

    ripe-article-50191

    11/25/2022, 8:06 AM
    @survey_definitions = SurveyDefinition.distinct.where.associated(:survey_responses)
  • d

    delightful-beach-23533

    11/30/2022, 3:50 PM
    hi, is it possible to use cards in normal resource? looking to have graphs, cards to display information about a customer, or do they only work in dashboard?
    l
    s
    • 3
    • 38
  • q

    quiet-winter-98496

    12/01/2022, 11:26 AM
    Does anyone know of a way to create a nested resource when you create a new resource? For example, if I have a model with a belongs_to association, I'd like to be able to create one of the belongs_to automatically when I create the parent model. I can do this using activerecord callbacks but if I wasn't using avo and I had complete control over the controllers I'd make a form object class that did this for me. Is there a way to do that in an avo resource? Perhaps using hidden fields and
    accepts_nested_attributes
    ?
    l
    • 2
    • 18
  • s

    straight-mechanic-78430

    12/02/2022, 9:52 AM
    Hi ๐Ÿ™‚ quick question, where can I add quick some css style to be used in some avo resources ? any ideas ?
  • s

    straight-mechanic-78430

    12/02/2022, 10:45 AM
    Hi All, How is the standard way of binding a stimulus controller in a newly created custom avo field ? I cant find any documentation about that ? can someone please help?
    l
    • 2
    • 2
  • s

    straight-mechanic-78430

    12/02/2022, 10:45 AM
    thanks a lot
  • l

    lemon-wall-20836

    12/02/2022, 3:53 PM
    bind stimulus controllers in a custom field
  • d

    delightful-beach-23533

    12/06/2022, 2:09 PM
    Hi all, i was wondering if there is a way to set a default sort ? i checked documentation and couldnt find anything
    l
    • 2
    • 6
  • l

    lemon-spoon-80671

    12/07/2022, 6:59 AM
    Hi all, I am trying to add a custom sortable block (as described here: https://docs.avohq.io/2.0/field-options.html#custom-sortable-block) on a computed field (as described here: https://docs.avohq.io/2.0/field-options.html#computed-fields) but get the following error:
    ActiveRecord::UnknownAttributeReference in Avo::SessionExecutionsController#index
    Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "session_executions.Session name desc".This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql().
    Has anyone had the same problem? Any hints? Thanks ๐Ÿ™‚
    s
    • 2
    • 18
  • s

    shy-notebook-24668

    12/07/2022, 8:40 AM
    Field options | Avo docs
  • w

    wide-carpet-65757

    12/08/2022, 11:45 AM
    Hi, did someone has try to use avo gem with activeresource? https://github.com/rails/activeresource
    l
    • 2
    • 3
  • r

    ripe-article-50191

    12/14/2022, 9:45 AM
    Add authorization to dashboard depending on the user role
  • r

    ripe-article-50191

    12/14/2022, 9:49 AM
    I am trying to find how can I prohibit or redirect, for example when a user with "client" role tries to load admin_dashboard URL
    l
    • 2
    • 17
  • l

    lemon-wall-20836

    12/14/2022, 11:21 AM
    I am trying to find how can I prohibit
  • c

    creamy-ghost-62907

    12/19/2022, 12:04 AM
    Has anyone here had luck integrating Papertrail with an Avo setup?
  • c

    creamy-ghost-62907

    12/19/2022, 12:09 AM
    I'm actually having trouble with a related item as well: I want ActiveAdmin comments to be available as well. In the case of my test resource, I've defined explicit associations on the model for those and I still can't get things working:
1...505152...64Latest