Skip to content

Commit

Permalink
Improve endpoint scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaier committed Aug 8, 2014
1 parent 0067b7a commit 7b933e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/pliny/commands/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def field_name
name.tableize.singularize
end

def fields_name
name.tableize.pluralize
end

def table_name
name.tableize
end
Expand All @@ -101,6 +105,7 @@ def create_endpoint(options = {})
plural_class_name: plural_class_name,
singular_class_name: singular_class_name,
field_name: field_name,
fields_name: fields_name,
url_path: url_path,
})
display "created endpoint file #{endpoint}"
Expand Down
5 changes: 2 additions & 3 deletions lib/pliny/templates/endpoint_scaffold.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ module Endpoints
end

get do
resources = uuid_paginator(<%= singular_class_name %>, args: { max: 10 })

MultiJson.encode serialize(resources)
<%= fields_name %> = uuid_paginator(<%= singular_class_name %>, args: { max: 10 })
MultiJson.encode serialize(%= fields_name %)
end

post do
Expand Down

0 comments on commit 7b933e3

Please sign in to comment.