Skip to content

Commit 1c9d1d3

Browse files
committed
Improve endpoint scaffold
1 parent 0b7691f commit 1c9d1d3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/pliny/commands/generator.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def field_name
8282
name.tableize.singularize
8383
end
8484

85+
def fields_name
86+
name.tableize.pluralize
87+
end
88+
8589
def pluralized_file_name
8690
name.tableize
8791
end
@@ -101,6 +105,7 @@ def create_endpoint(options = {})
101105
plural_class_name: plural_class_name,
102106
singular_class_name: singular_class_name,
103107
field_name: field_name,
108+
fields_name: fields_name,
104109
url_path: url_path,
105110
})
106111
display "created endpoint file #{endpoint}"

lib/pliny/templates/endpoint_scaffold.erb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ module Endpoints
66
end
77

88
get do
9-
resources = uuid_paginator(<%= singular_class_name %>, args: { max: 10 })
10-
11-
encode serialize(resources)
9+
<%= fields_name %> = uuid_paginator(<%= singular_class_name %>, args: { max: 10 })
10+
encode serialize(%= fields_name %)
1211
end
1312

1413
post do

0 commit comments

Comments
 (0)