thankful-stone-82785
11/13/2022, 1:41 PMInvoice
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"=>""}
thankful-stone-82785
11/13/2022, 1:43 PMvictorious-kangaroo-12568
11/14/2022, 9:57 PMfield :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 ?ripe-article-50191
11/17/2022, 10:42 AMripe-article-50191
11/17/2022, 10:44 AMmammoth-guitar-49791
11/22/2022, 11:52 AMaspect_ratio, decimal
and I have it assigned to a text input on avo.
on my model i have
ruby
before_save :convert_aspect_ratio
def convert_aspect_ratio
self.aspect_ratio = aspect_ratio.to_r.to_f
end
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?lemon-wall-20836
11/22/2022, 12:13 PMstraight-mechanic-78430
11/23/2022, 12:28 PMmammoth-guitar-49791
11/23/2022, 3:08 PMmammoth-guitar-49791
11/23/2022, 4:12 PMruby
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
straight-mechanic-78430
11/24/2022, 9:52 AMruby
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 ?lemon-wall-20836
11/24/2022, 10:55 AMmammoth-guitar-49791
11/24/2022, 2:08 PMruby
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
ripe-article-50191
11/25/2022, 8:06 AMripe-article-50191
11/25/2022, 8:06 AM@survey_definitions = SurveyDefinition.distinct.where.associated(:survey_responses)
delightful-beach-23533
11/30/2022, 3:50 PMquiet-winter-98496
12/01/2022, 11:26 AMaccepts_nested_attributes
?straight-mechanic-78430
12/02/2022, 9:52 AMstraight-mechanic-78430
12/02/2022, 10:45 AMstraight-mechanic-78430
12/02/2022, 10:45 AMlemon-wall-20836
12/02/2022, 3:53 PMdelightful-beach-23533
12/06/2022, 2:09 PMlemon-spoon-80671
12/07/2022, 6:59 AMActiveRecord::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 ๐shy-notebook-24668
12/07/2022, 8:40 AMwide-carpet-65757
12/08/2022, 11:45 AMripe-article-50191
12/14/2022, 9:45 AMripe-article-50191
12/14/2022, 9:49 AMlemon-wall-20836
12/14/2022, 11:21 AMcreamy-ghost-62907
12/19/2022, 12:04 AMcreamy-ghost-62907
12/19/2022, 12:09 AM