# Server Side Swift with Vapor - Part 23: Creating | Ray Wenderlich

**URL:** <https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 7, 2018, 3:02am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090 "2018-03-07T03:02:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 7, 2018, 3:02am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/1 "2018-03-07T03:02:49Z")

</div>

Learn how to send data with web forms and accept the data back in our Vapor application to create models.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/4493-server-side-swift-with-vapor/lessons/23](https://www.raywenderlich.com/4493-server-side-swift-with-vapor/lessons/23)

---

<div class="post-metadata">

**Author:** ![fahim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fahim/32/110943_2.png) [@fahim](https://forums.kodeco.com/u/fahim)\
**Post date:** [March 8, 2018, 1:20am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/2 "2018-03-08T01:20:12Z")

</div>

A few notes about this video that might help clear up confusion:

1. You can also re-use the existing `AllUsersContext` (or whatever you called it in your code) that was previously created to display the list of users instead of creating a new `CreateAcronymContext` for creating a user. Correct me if I’m wrong, but I believe the only reason to create a new context is to keep the contexts separate in case you need to make changes to one screen or the other in the future …

2. The instructions to add a new `init` method to the `Acronym` class might be confusing to those who followed along since I believe this was already done previously for another video. (I would have to look it up to see which one exactly. Might have been a challenge and that is why it was re-done here but for those who did the challenges, this might be very confusing …)

3. Also at about 6:30 there is a slight duplication in audio where it says “to perform a redirect …” twice 🙂

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 8, 2018, 10:57am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/3 "2018-03-08T10:57:36Z")

</div>

1 - Yep you can. It does get reused for the Edit page, which becomes even more helpful if on errors you pass the acronym back to the page to pre-populate the fields etc. But I didn’t want to confuse people too much!

2 - Ah yeah, that’s my bad. In the original betas (and Swift 4.0) when the videos were originally recorded, if you declared a class `Codable` you didn’t need to provide an initialiser. That isn’t the case any more in 4.1 😞

3 - Thanks for letting me know!

Thanks for the feedback! 😃

---

<div class="post-metadata">

**Author:** ![fahim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fahim/32/110943_2.png) [@fahim](https://forums.kodeco.com/u/fahim)\
**Post date:** [March 8, 2018, 11:52am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/4 "2018-03-08T11:52:58Z")

</div>

Happy to help 🙂 As I mentioned before, I’m really enjoying the video series and am looking forward to running a few apps on my server.

Of course, before that, I need to compile Swift for CentOS since my server runs CentOS. Been compiling for the last few hours - not sure if it will work or not since others have reported mixed success in compiling Swift for different Linux platforms 😃

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 8, 2018, 12:09pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/5 "2018-03-08T12:09:13Z")

</div>

@fahim yeah unfortunately we’re kinda at the mercy of Apple there for different Linux support. Theoretically it should all work, but people have had issues with edge cases with glibc versions. Honestly I would just run it in a Docker container and then you can run it on whatever OS you want!

---

<div class="post-metadata">

**Author:** ![fahim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fahim/32/110943_2.png) [@fahim](https://forums.kodeco.com/u/fahim)\
**Post date:** [March 8, 2018, 12:24pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/6 "2018-03-08T12:24:18Z")

</div>

> [@0xtim](#):
>
> Honestly I would just run it in a Docker container and then you can run it on whatever OS you want!

That’s my plan B if I fail to get things to compile correctly. It just finished the initial build file creation successfully. So I’m still being hopeful, but you know how it is … Guess I’ll find out soon enough 😛

---

<div class="post-metadata">

**Author:** ![doyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doyle/32/102075_2.png) [@doyle](https://forums.kodeco.com/u/doyle)\
**Post date:** [March 27, 2018, 12:19pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/7 "2018-03-27T12:19:21Z")

</div>

when I Submit on the Create An Acronym page, the page loads to “[http://localhost:8080/acronyms/11](http://localhost:8080/acronyms/11)” and displays “Oops: This parent relationship could not be resolved”.

The home page still displays all the acronyms I add. I did “vapor xcode -y” on the Download Materials example project and ran it but it does the same thing.

Xcode says:  
Migrating mysql DB  
Migrations complete  
Server starting on [http://localhost:8080](http://localhost:8080)  
[ERROR] FluentError.parentRequired: This parent relationship could not be resolved (Parent.swift:38)

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 27, 2018, 3:26pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/8 "2018-03-27T15:26:38Z")

</div>

@doyle hmm sounds like your database has been mismatched. Have you been been moving back and forth between projects. Basically it sounds like the `userID` column in missing. What you can try is kill the database and starting it up again:

```bash
docker stop mysql
docker rm mysql
docker run --name mysql -e MYSQL_USER=til -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=vapor -p 3306:3306 -d mysql/mysql-server

```

Rerun your app and it should work.

---

<div class="post-metadata">

**Author:** ![doyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doyle/32/102075_2.png) [@doyle](https://forums.kodeco.com/u/doyle)\
**Post date:** [March 27, 2018, 4:32pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/9 "2018-03-27T16:32:13Z")

</div>

> [@0xtim](#):
>
> docker stop mysql

Thanks, tried that but still gives the same error.

I can move around the site to the various pages but when I click submit and get the error, I can no longer load any of the pages and have run Xcode again. Once reloaded the previous acronym shows up.

I cleaned the project and deleted derived data. Restarted the mac, dowloaded a fresh copy of the download material, redid the docker stop and rm steps. Getting the same error.

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 27, 2018, 6:54pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/10 "2018-03-27T18:54:57Z")

</div>

@doyle that is weird. If you use the API does it work? And if you connect to the MySQL DB via the command line can you inspect the table structure - does it have the `userID` column in it?

After you downloaded the materials did you run `vapor update` to get the latest RC? I don’t think the download materials have been updated as they are waiting for the new videos to go up.

---

<div class="post-metadata">

**Author:** ![doyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doyle/32/102075_2.png) [@doyle](https://forums.kodeco.com/u/doyle)\
**Post date:** [March 29, 2018, 12:58am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/11 "2018-03-29T00:58:07Z")

</div>

Got it working using your instructions in the part 22 forum:

> [@Server Side Swift with Vapor - Part 22: Challenge: | Ray Wenderlich](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-22-challenge-ray-wenderlich/40081/34):
>
> I think it’s now fixed - try running vapor update and it should work again

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 5, 2018, 9:52pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-23-creating-ray-wenderlich/40090/13 "2018-08-05T21:52:18Z")

</div>

Opened on August 5, 2018, 9:52pm UTC


