https://avo.cool logo
I think I'm running into an issue and I'm not s...
# avo-2
m
I think I'm running into an issue and I'm not sure if I'm doing anything wrong in the setup. I have a Picture/Video model that inherits from Medium. and resource is NIL on the show view of medium.
Copy code
ruby
class MediumResource < Avo::BaseResource
  field :utm_parameter, as: :has_one, only_on: :show
end
class Medium < ApplicationRecord
  has_one :utm_parameter, dependent: :destroy
end
class UtmParameter < ApplicationRecord
  belongs_to :medium
end
class UtmParameterResource < Avo::BaseResource
  self.title = :id

  field :utm_source, as: :text
  field :utm_medium, as: :text
  field :utm_campaign, as: :text
end
# frozen_string_literal: true

class MediumPolicy < ApplicationPolicy
  def index?
    admin?
  end

  def show?
    true
  end

  def edit?
    true
  end

  def create?
    true
  end

  def update?
    true
  end

  def view_utm_parameter
    true
  end

  class Scope < Scope
    def resolve
      scope.all
    end
  end
end
Copy code
ruby
undefined method `authorization' for nil:NilClass

        service = resource.authorization
                          ^^^^^^^^^^^^^^
https://cdn.discordapp.com/attachments/740893011994738751/1290960151213379584/image.png?ex=66fe5bd4&is=66fd0a54&hm=660a09b050c6d396e149b111173ae7edbe3ca62a701af7653c92a72b89df89f6&
m
Thread automatically created by Justin Marsh in #740893011994738751
m
Copy code
ruby
irb(Avo::App):013:0> valid_resources.map{_1.model_class.model_name.name}
=> ["Yael::Event", "Audio", "Category", "Faq", "Medium", "Picker", "PickerValue", "Medium", "Review", "Scene", "Theme", "ThemeCategory", "User", "UtmParameter", "Medium", "VideoScene", "Watermark"]
irb(Avo::App):014:0>           valid_resources
irb(Avo::App):015:1*             .find do |resource|
irb(Avo::App):016:1>               resource.model_class.model_name.name == klass.to_s
irb(Avo::App):017:0>             end
=> nil
irb(Avo::App):018:0>
Copy code
ruby
irb(Avo::App):011:0> valid_resources
=>
[#<ActivityResource:0x000000011d355c28>,
 #<AudioResource:0x000000011d355db8>,
 #<CategoryResource:0x000000011d355f20>,
 #<FaqResource:0x000000011d355f98>,
 #<MediumResource:0x000000011d356010
  @model=
   #<Picture:0x000000011d859e18
    id: "8d63da03-244a-406c-93db-e6c195b35023",
    theme_id: "25a6d738-d107-48f3-8cbd-922f22f33187",
    status: "draft",
    created_at: Tue, 01 Oct 2024 01:13:58.346949000 CEST +02:00,
    updated_at: Tue, 01 Oct 2024 22:35:28.405402000 CEST +02:00,
    user_id: nil,
    reminder_sent_at: nil,
    purchased_at: nil,
    positive_feedback: nil,
    audio_id: nil,
    viewed_at: nil,
    type: "Picture",
    price: 0.299e1>,
  @params=#<ActionController::Parameters {"controller"=>"avo/media", "action"=>"show", "id"=>"8d63da03-244a-406c-93db-e6c195b35023"} permitted: false>,
  @user=
   #<User:0x000000011cb26ef8
    id: "ae6c10d0-0b13-554c-b976-a05d8a18f0cc",
    first_name: "I AM",
    last_name: "ROOT",
    email: "admin@example.com",
    locale: "en",
    roles: ["admin"],
    created_at: Tue, 17 Sep 2024 17:17:03.882531000 CEST +02:00,
    updated_at: Tue, 17 Sep 2024 17:17:03.882531000 CEST +02:00,
    password_digest: "$2a$12$EdUuqdbpowRJvcUIVXOZb.YDyi8TZVHY2vVlrfA.50mFULME2NIgG">,
  @view=:show>,
 #<PickerResource:0x000000011d356088>,
 #<PickerValueResource:0x000000011d356100>,
 #<PictureResource:0x000000011d356178>,
 #<ReviewResource:0x000000011d3561f0>,
 #<SceneResource:0x000000011d356290>,
 #<ThemeResource:0x000000011d356678>,
 #<ThemeCategoryResource:0x000000011d3563a8>,
 #<UserResource:0x000000011d3566f0>,
 #<UtmParameterResource:0x000000011d356768>,
 #<VideoResource:0x000000011d3567e0>,
 #<VideoSceneResource:0x000000011d356858>,
 #<WatermarkResource:0x000000011d356920>]
I think the issue is here
l
Hey @mammoth-guitar-49791 this seems a very specific error, are you able to provide an reporduction repository and create an issue?
( I still didn't get the chance to look into the time picker one sorry for the delay )