lemon-wall-20836
07/07/2022, 3:55 PMloud-jewelry-99127
07/11/2022, 1:53 PMloud-jewelry-99127
07/11/2022, 1:53 PMloud-jewelry-99127
07/11/2022, 1:54 PMloud-jewelry-99127
07/11/2022, 1:54 PMloud-jewelry-99127
07/11/2022, 2:40 PMgreen-london-56146
07/11/2022, 2:59 PMlemon-wall-20836
07/11/2022, 3:03 PMlemon-wall-20836
07/11/2022, 3:04 PMorder resourcefaint-belgium-54046
07/12/2022, 5:04 PMsome-army-14041
07/13/2022, 6:28 AMsome-army-14041
07/13/2022, 6:36 AMlemon-wall-20836
07/13/2022, 8:09 AMbright-tomato-27372
07/14/2022, 6:36 AMhas_many_through associations where the JOINs table has extra fields to display?
For example, let's say there's Recipe, Ingredient, and RecipeIngredients to JOIN the two tables.
class Recipe
has_many :recipe_ingredients
has_many :ingredients, through: :recipe_ingredients
end
class Ingredient
has_many :recipe_ingredients
has_many :recipes, through: :recipe_ingredients
end
class RecipeIngredient < ApplicationRecord
belongs_to :recipe
belongs_to :ingredient
# also has a 'quantity' attribute to show the quantity of the ingredients in the recipe
end
In my recipe_resource.rb, I have field :ingredients, as: :has_many, through: :recipe_ingredients.
The #show page shows the details for the Ingredient, but I also want to show the ingredient.quantity after the Ingredient fields. I'm probably missing something small and silly, but how can I show the quantity from RecipeIngredient on the Recipe#show page? And make the quantity editable from the Recipe#edit?lemon-wall-20836
07/14/2022, 8:19 AMbright-tomato-27372
07/15/2022, 5:58 AMcurrent_user inside of a Avo resource file?
Reason is I'm saving a resource that belongs_to a User and needs a user_id (the id of the currently signed in user). I'm attempting something like this: field :user_id, as: :hidden, default: @current_user.id inside of the resource. Would it need to be set in the ApplicationController?early-camera-94059
07/16/2022, 12:24 PM/avo it is failing to find the schema method used to define schemas. This is not a problem loading other controllers. Any ideas why Avo might hit this issue?lemon-wall-20836
07/16/2022, 2:39 PMearly-camera-94059
07/16/2022, 4:38 PM/avo/photos/123 which doesnt work.lemon-wall-20836
07/16/2022, 8:26 PMearly-camera-94059
07/17/2022, 9:07 AMconfig.authorization_methods is defined to add an avo_ prefix to each policy method, does the same get applied to the attach_{association}? methods?early-camera-94059
07/18/2022, 9:43 AMlemon-wall-20836
07/18/2022, 9:53 AMfaint-belgium-54046
07/18/2022, 4:07 PMfaint-belgium-54046
07/18/2022, 4:07 PMfaint-belgium-54046
07/18/2022, 4:07 PMsome-army-14041
07/19/2022, 1:41 PMlemon-wall-20836
07/19/2022, 4:01 PMworried-machine-9922
07/19/2022, 4:06 PMclass DuplicateRecord < Avo::BaseAction
self.name = "Duplicate record"
def handle(**args)
models, resource = args.values_at(:models, :resource)
model = models.first
redirect_to resource.avo.new_resources_prediction_path(duplicate_of_id: model.id)
silent
end
end
And this here concern I'm including in relevant `Avo::ResourcesController`s.
module Avo::Duplicable
def new
super
if params[:duplicate_of_id]
@model = Prediction.find(params[:duplicate_of_id]).dup
@resource = @resource.hydrate(model: @model, view: :new, user: _current_user)
end
end
end
The problem is the point in the Action where you're `redirect_to`'d avo.new_resources_predictions_path, Prediction being a model in my app. I am looking for a way to generate the appropriate path for any arbitrary resource.
I have tried avo.polymorphic_path but that points me at prediction_path, which does not exist, and is not appropriate for the new action anyway.
tl;dr: Given an arbitrary Avo resource or AR model, I would like to have a way to call new_resourses_RESOURCENAME_path appropriate for the resource or model.narrow-laptop-54609
07/19/2022, 6:45 PM