Skip to content

Commit 10e77c7

Browse files
Dogan AYmatthv
authored andcommitted
fix: activeStorage
1 parent 126e4ac commit 10e77c7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/services/forest_liana/resources_getter.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,21 @@ def compute_select_fields
304304
association = get_one_association(association.options[:through])
305305
end
306306

307+
# For ActiveStorage associations, include all required columns
307308
if is_active_storage_association?(association)
309+
# Include all columns from ActiveStorage tables to avoid initialization errors
310+
table_name = association.table_name
311+
association.klass.column_names.each do |column_name|
312+
select << "#{table_name}.#{column_name}"
313+
end
314+
315+
# Also include the foreign key from the main resource (e.g., blob_id, record_id)
316+
if association.macro == :belongs_to || association.macro == :has_one
317+
foreign_keys = Array(association.foreign_key)
318+
foreign_keys.each do |fk|
319+
select << "#{@resource.table_name}.#{fk}"
320+
end
321+
end
308322
next
309323
end
310324

0 commit comments

Comments
 (0)