In the last episode, we got our rough data model and persistence layer worked out. Now, we'd like to make our web app use that persistence layer when a user submits data.
The first step is to extract our Amnesia records from the test we built them in, directly into the application itself. Let's go ahead and do that by moving the database code into
... hack hack hack ...
Now that that's done, we should be able to just feed the form data that was sent in by the user into a
Dweet record, and show all the
Dweets from newest to oldest on the homepage:
(The following needs to go in the
lib/dwitter.ex file, before starting the Dwitter Dynamo:
Amnesia.Schema.create Amnesia.start Dwitter.Database.destroy Dwitter.Database.create
So you are aware, for now this will blow away the database and recreate it each time we restart the server.
Now, let's modify the existing router and make it store a new Dweet each time the form is submitted. Open up
To see the complete version of this and more awesome articles become a superuser or login