Skip to content

Commit 546e120

Browse files
author
Olivier Bonnaure
committed
fix: update controller template
1 parent 37a2c93 commit 546e120

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

.templates/controller.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ local app = {
3030
-- PUT ##model_plural###update => ##model_plural##/:id
3131
update = function()
3232
local bodyParams = table.reject(GetBodyParams(), "authenticity_token")
33-
local record = ##model_singular_capitalized##.update(Params.id, bodyParams)
33+
local ##model_singular## = ##model_singular_capitalized##.update(Params.id, bodyParams)
3434

35-
if record.error then
35+
if ###model_singular##.errors > 0 then
3636
Page("##model_plural##/edit", "app", { ##model_singular## = table.merge(bodyParams, { _key = Params.id }), record = record })
3737
return
3838
end

.templates/migration.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ return {
77
},
88
})
99
if
10-
pcall(function()
11-
assert(transaction.code == 201, "Transaction is not created")
12-
-- do something
13-
end)
10+
pcall(function()
11+
assert(transaction.code == 201, "Transaction is not created")
12+
-- do something
13+
end)
1414
then
1515
Adb.primary:CommitTransaction(transaction.result.id)
1616
return true
@@ -28,10 +28,10 @@ return {
2828
},
2929
})
3030
if
31-
pcall(function()
32-
assert(transaction.code == 201, "Transaction is not created")
33-
-- do something
34-
end)
31+
pcall(function()
32+
assert(transaction.code == 201, "Transaction is not created")
33+
-- do something
34+
end)
3535
then
3636
Adb.primary:CommitTransaction(transaction.result.id)
3737
return true

0 commit comments

Comments
 (0)