Update: I should have called the var passed to the prepare closure acronyms rather than users to be more clear. Calling it users was a holdover from an old version of the project.
Thanks you so much Ray for all the Vapor tutorials.
They work fine on my laptop but all related to database doesnāt work on Heroku.
Is there a specific configuration or 'hack" to know ?
@pourpre There is indeed. To get this to work on Heroku, you need to install a PostgreSQL DB on the cloud and configure your Heroku app to point to it. Good news - thatās the subject of my next Screencast :] Hope you enjoy it and thanks for reading our site! :]
is there a reason why you used touch to add a file to the project versus just doing it via the XCode IDE? maybe a stupid question but I am just curious.
@dniswhite Yes - my understanding is that itās best to use the file system for all file & directory creation, and treat the Xcode project as a āblack boxā generated by vapor xcode. I think of the xcode project as a āconvenient alternativeā way to build the project, with the primary method being vapor build (which runs swift build under the hood). If anyone understands this differently, let me know.
Hello, Ray!
Thank you for Vapor tutorials! Thatās cool!!!
But I canāt fix a bug.
When I launch the application, i see in console:
Could not initialize provider Provider: noPostgreSQLConfig
No command supplied, defaulting to serveā¦
Can not run preparations, droplet has no database
Program ended with exit code: 1
Iām really enjoying these videos, but Iāve come across a strange behavior that Iām trying to figure out.
This drop results in a the same data being inserted twice each time itās called:
drop.get(ātestā) { request in
var acronym = Acronym(short: āOMWā, long: āOn My Wayā)
try acronym.save()
return try JSON(node: Acronym.all().makeNode())
}
Actually any save() does that. All the code in Acronym.swift is a straight copy from the video. I should add this is Xcode 8 as well. Is this something Iām doing wrong, based on this snippet?
drop.get("add-data") { req in
var acronym = Acronym(short: "YOLO", long: "You Only Live Once")
try acronym.save()
return "made acronym"
}
drop.get("get-data") { req in
return try JSON(node: Acronym.all().makeNode())
}
I am new to server-side programming so I donāt know how web browsers work. In the url field, I typed in ā¦/add-data and pressed return key. the DB works fine. then typed ā¦/get-data it reads well. however, when i change the letters āgetā to āaddā in the url field of a web browser. the drop.get(āadd-dataā) already executes before pressing Return key. and when I press Return key it invokes one more time. So the data got written twice to the DB. Is this normal?