Skip to content

Commit cf408d1

Browse files
committed
Improve endpoint scaffold
1 parent f2c0f33 commit cf408d1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/pliny/commands/generator/base.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def field_name
2727
name.tableize.singularize
2828
end
2929

30+
def fields_name
31+
name.tableize.pluralize
32+
end
33+
3034
def pluralized_file_name
3135
name.tableize
3236
end

lib/pliny/commands/generator/endpoint.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def create
1010
plural_class_name: plural_class_name,
1111
singular_class_name: singular_class_name,
1212
field_name: field_name,
13+
fields_name: fields_name,
1314
url_path: url_path)
1415
display "created endpoint file #{endpoint}"
1516
display 'add the following to lib/routes.rb:'

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)