Ok been stuck on this thing :D I have this resource:
defmoduleNoSpark.Builder.DindouseAsh.Resource,data_layer:AshSqlite.DataLayersqlitedotable"dins"repoNoSpark.Repoendattributesdouuid_primary_key:idattribute:label,:stringattribute:description,:stringattribute:slots,:integerdoallow_nil?falseconstraintsmin:0endendrelationshipsdobelongs_to:schema,NoSpark.Builder.Schemaendcode_interfacedodefine_for(NoSpark.Builder)define(:create)define(:read)define(:update)endactionsdodefaults[:create,:read,:update,:destroy]endend
And i want to create the din with a schema already attached.
All you really need to do is update the relationshipbelongs_to
to make it writable:
belongs_to:schema,NoSpark.Builder.Schemadoattribute_writable?trueend
And now you can create your resource with the schema relationship attached like so:
Din.create!(%{label:"Din X",slots:schema.slots,schema_id:schema.id})
Whereschema
is just some schema which is already created.
This took me a while to figure out :D Hope this helps you!
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse