-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Depends on #331
class ArticleBox < Box
def initialize
post { PostBox.create }
end
# This is auto-generated by the box. Putting it here just to show rough implementation
def post
before_save do
if post_id.value.blank?
record_or_id = yield
id = if record_or_id.is_a?(Avram::Model)
record_or_id.id
else
record_or_id
end
post_id id
end
end
end
endThis will most likely require changes to https://github.com/luckyframework/avram/blob/master/src/avram/save_operation.cr so that we have access to an ASSOCIATIONS constant that has a list of associations and the column to use.
Relevant examples:
add_column_attributes({{ primary_key_type }}, {{ columns }}) avram/src/avram/save_operation.cr
Lines 80 to 82 in d67dd63
{% for attribute in attributes %} {% COLUMN_ATTRIBUTES << attribute %} {% end %}
We'd want to add a add_association_attributes or something. This will be a bit more complex so I'll try to tackle it, but if someone else wants to take a stab at it, post here and I'll try to help if you run into anything
Metadata
Metadata
Assignees
Labels
No labels