I am new to Elixir and Phoenix, and I have hit a wall. I have troubles creating, with one Web page, 3 entries in our database. Here's what's happenning:
We have three tables:
Events <-> Event_Actions <-> Actions
Events and Actions are linked through a many_to_many association called Event_Action. Events actually have 3 many_to_many associations with Actions, through three different tables with different fields, but for the sake of the example I've simplified it to one.
When using the Phoenix Web interface, there is an error upon submitting the form.
The Event and Action entries are correctly created but an exception is raised for the association. For some reason, the Timestamps are not inserted even though they are present in all the schemas.
If I look into the queries outputs, I can see the INSERT INTO actions or events have the timestamps fields but not the "event_actions".
Timestamps are missing upon insertion
If I run the function manually from iex or unit testing it, it works, the problem only happens when it is executed from the web display.
def create_action_on_start(event_id, action_id) do
payload = %Event_Start_Action{
event_id: event_id,
action_id: action_id
}
Repo.insert(payload)
end
While I'm here I've got another question for you, as it is the goal I'm trying to achieve with this system.
I'm trying to create a dynamic form, with the possibility to add / remove Actions on the fly and update the form accordingly.
Besides, the tables schema is slightly more complicated as above. Actions have Targets (which basically are a bunch of fields that act as filters) and are also connected via a many_to_many association . So it looks more like that:
Events <-> Event_Actions <-> Actions <-> Action_Targets <-> Targets
But I am unable either to render the Actions dynamically nor the Targets information related to the Action. Do you have any advice on the subject ? Thank you so much !
PS: I already have a post on reddit, but I did not get the answers I was hoping for.
Aucun commentaire:
Enregistrer un commentaire