app/models/upload/graphic.rb
class Upload::Graphic < ApplicationRecord
belongs_to :order, class_name: "Spree::Order", optional: true
has_one_attached :image
def order
Spree::Order.find(spree_order_id)
end
end
migration
class CreateUploadGraphics < ActiveRecord::Migration[6.1]
def change
create_table :upload_graphics do |t|
t.references :spree_order, foreign_key: true
t.timestamps
end
end
end
This part works great i can do .order on an Upload::Graphic object and it returns the order.
Question: how do i do the inverse? Start with a Spree::Order and find the Upload::Graphic