I was having a problem using the active scaffold's subform when creating child objects in the create form. I had a class ClassSections that has_one Course. When I clicked "create new" in the AS scaffold I had the opportunity to enter a new Course in the Course subform that shows on the ClassSections's create form. However, when I saved it , it returned an error telling me that "Course can't be null". I was surpirsed since I could choose an existing Course but not create one from that form.
After some time, I discovered that the culprit was that I had a validation in the ClassSections class to prevent the course_id to be null (validates_nullability_of :course) and in the RDBMS I had also a NOT NULL constraint in the foreign key. I disabled both constrains (in the class and in the RDBMS) and now it works.
The lesson learned: In Active scaffold, if you want to be able to create objects for the has_one relationship in the Create form's has_one subform, you must disable any validation or contraint that prevents the foreign key to be null.
Construct2 can use websockets to send and receive messages between games. By using socket-io , we can use a Node.js script as the server and my modification to the socket-io plugin for Construct2 to allow the games to synchronize data between them in real-time. There are two parts to this design: the Node.js server and the Construct2 clients (the games playing). The main part of building an online multiplayer HTML5 game is to plan: how the clients will communicate how often and what to communicate how much of the logic will go into the server and how much to the client. In my sample game, I chose to have each client own a player and have the server just relay messages: Use string messages in the form TypeOfMessage, Parameter1, Paremeter2, Parater3, etc to communicate. Have the clients send their player position about 16 times a second. Whenever their player shoots, the client needs to send a message immediately. Almost all of the game logic will...
Comments