acceptable-cartoon-88076
07/17/2023, 4:42 PMacceptable-cartoon-88076
07/17/2023, 4:50 PMpanel name: "Project Information" do
field :name, as: :text
field :notes, as: :textarea
field :active, as: :boolean
end
panel name: "Project Resources" do
tabs do
tab "Sites", description: "Sites" do
field :sites, as: :has_many
end
tab "Workflows", description: "Workflows" do
field :workflows, as: :has_many
end
tab "Datasets", description: "Datasets" do
field :datasets, as: :has_many
end
end
Site resource is straight forward:
class SiteResource < Avo::BaseResource
self.authorization_policy = AccountMemberPolicy
self.title = :id
self.includes = []
# self.search_query = -> do
# scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
# end
field :id, as: :id
# Fields generated from the model
field :name, as: :text
field :url, as: :text
field :classification, as: :select, options: Site.classifications_for_select(:titleize)
# add fields here
end
acceptable-cartoon-88076
07/17/2023, 4:50 PMacceptable-cartoon-88076
07/17/2023, 4:51 PMweb_1 | 16:36:41 web.1 | Started POST "/a/resources/sites?via_relation=project&via_relation_class=Project&via_resource_id=2" for 172.25.0.1 at 2023-07-17 16:36:41 +0000
web_1 | 16:36:41 web.1 | Cannot render console from 172.25.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
web_1 | 16:36:41 web.1 | User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]]
web_1 | 16:36:41 web.1 | Processing by Avo::SitesController#create as TURBO_STREAM
web_1 | 16:36:41 web.1 | Parameters: {"authenticity_token"=>"[FILTERED]", "via_resource_id"=>"2", "via_relation"=>"project", "site"=>{"name"=>"[FILTERED]", "url"=>"https://google.com", "classification"=>"competitor_site"}, "button"=>"", "via_relation_class"=>"Project"}
web_1 | 16:36:41 web.1 | Account Load (0.6ms) SELECT "accounts".* FROM "accounts" INNER JOIN "account_users" ON "accounts"."id" = "account_users"."account_id" WHERE "account_users"."user_id" = $1 AND "accounts"."id" = $2 LIMIT $3 [["user_id", 2], ["id", 3], ["LIMIT", 1]]
web_1 | 16:36:41 web.1 | ↳ app/controllers/concerns/set_current_request_details.rb:36:in `account_from_session'
web_1 | 16:36:41 web.1 | Pay::Customer Load (0.6ms) SELECT "pay_customers".* FROM "pay_customers" WHERE "pay_customers"."owner_type" = $1 AND "pay_customers"."default" = $2 AND "pay_customers"."deleted_at" IS NULL AND "pay_customers"."owner_id" = $3 [["owner_type", "Account"], ["default", true], ["owner_id", 3]]
web_1 | 16:36:41 web.1 | ↳ app/controllers/concerns/set_current_request_details.rb:36:in `account_from_session'
web_1 | 16:36:41 web.1 | AccountUser Load (0.4ms) SELECT "account_users".* FROM "account_users" WHERE "account_users"."account_id" = $1 [["account_id", 3]]
web_1 | 16:36:41 web.1 | ↳ app/controllers/concerns/set_current_request_details.rb:36:in `account_from_session'
web_1 | 16:36:41 web.1 | User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 [["id", 2]]
web_1 | 16:36:41 web.1 | ↳ app/controllers/concerns/set_current_request_details.rb:36:in `account_from_session'
web_1 | 16:36:41 web.1 |
web_1 | 16:36:41 web.1 | Project Load (0.4ms) SELECT "projects".* FROM "projects" WHERE "projects"."account_id" = $1 AND "projects"."id" = $2 LIMIT $3 [["account_id", 3], ["id", 2], ["LIMIT", 1]]
web_1 | 16:36:41 web.1 | TRANSACTION (0.3ms) BEGIN
web_1 | 16:36:41 web.1 | Project Load (0.5ms) SELECT "projects".* FROM "projects" WHERE "projects"."account_id" = $1 AND "projects"."id" = $2 LIMIT $3 [["account_id", 3], ["id", 2], ["LIMIT", 1]]
web_1 | 16:36:41 web.1 | Site Create (0.7ms) INSERT INTO "sites" ("name", "url", "project_id", "classification", "raw_data", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["name", "Second Test Site"], ["url", "https://google.com"], ["project_id", 2], ["classification", 1], ["raw_data", nil], ["created_at", "2023-07-17 16:36:41.395792"], ["updated_at", "2023-07-17 16:36:41.395792"]]
web_1 | 16:36:41 web.1 | TRANSACTION (1.4ms) COMMIT
lemon-wall-20836
07/17/2023, 4:51 PMlemon-wall-20836
07/17/2023, 4:51 PMlemon-wall-20836
07/17/2023, 4:52 PMlemon-wall-20836
07/17/2023, 4:52 PMacceptable-cartoon-88076
07/17/2023, 4:52 PMlemon-wall-20836
07/17/2023, 4:52 PMlemon-wall-20836
07/17/2023, 4:52 PMacceptable-cartoon-88076
07/17/2023, 4:52 PMacceptable-cartoon-88076
07/17/2023, 4:52 PMacceptable-cartoon-88076
07/17/2023, 4:53 PMlemon-wall-20836
07/17/2023, 4:53 PMlemon-wall-20836
07/17/2023, 4:53 PMlemon-wall-20836
07/17/2023, 4:53 PMacceptable-cartoon-88076
07/17/2023, 4:53 PMlemon-wall-20836
07/17/2023, 4:54 PMrails new
and then hit it with bin/rails app:template LOCATION='https://avohq.io/app-template'
lemon-wall-20836
07/17/2023, 4:54 PMacceptable-cartoon-88076
07/17/2023, 4:54 PMlemon-wall-20836
07/17/2023, 4:54 PMacceptable-cartoon-88076
07/17/2023, 4:54 PMlemon-wall-20836
07/17/2023, 4:55 PMlemon-wall-20836
07/17/2023, 4:55 PMlemon-wall-20836
07/17/2023, 4:55 PMlemon-wall-20836
07/17/2023, 4:55 PMacceptable-cartoon-88076
07/17/2023, 7:09 PMfield :project, as: :belongs_to, visible: false
Just showing the field as-is works as-expected.
field :project_id, as: :hidden, default: -> {resource.params[:via_resource_id]}
works, based on the docs and figuring out how to find Project ID. Is there a better way vs digging into resource.params like that?lemon-wall-20836
07/18/2023, 6:31 AMlemon-wall-20836
07/18/2023, 6:31 AMlemon-wall-20836
07/18/2023, 6:33 AMlemon-wall-20836
07/18/2023, 6:33 AMacceptable-cartoon-88076
07/18/2023, 1:09 PMacceptable-cartoon-88076
07/18/2023, 1:09 PM