lib/generators/templates/rest/rest_endpoint.rb.erb in grape_resource-0.1.6 vs lib/generators/templates/rest/rest_endpoint.rb.erb in grape_resource-0.1.10
- old
+ new
@@ -7,20 +7,20 @@
paginate per_page: Pagy::VARS[:items], max_per_page: Pagy::VARS[:max_per_page]
get "/" do
results = <%= name.camelize.singularize %>.all
resources = paginate(results)
present_metas resources
- present :<%= name.underscore %>, resources, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
+ present :<%= name.underscore.pluralize %>, resources, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
end
desc "Get <%= name.underscore.singularize %> by id"
params do
requires :id, type: String
end
get "/:id" do
results = <%= name.camelize.singularize %>.find(params.id)
- present :<%= name.underscore %>, results, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
+ present :<%= name.underscore.singularize %>, results, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
end
desc "Create"
params do
<% @entities.each do |k, v| %>remove
@@ -29,11 +29,11 @@
end
post "/" do
p = <%= name.camelize.singularize %>.new <%= name.underscore.singularize %>_params
results = p.save!
present :status, results
- present :<%= name.underscore %>, p, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
+ present :<%= name.underscore.singularize %>, p, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
end
desc "Update"
params do
requires :id, type: String
@@ -42,10 +42,10 @@
<% end %>remove
end
put "/" do
p = <%= name.camelize.singularize %>.find(params.id)
p.update <%= name.underscore.singularize %>_params
- present :<%= name.underscore %>, p, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
+ present :<%= name.underscore.singularize %>, p, with: <%= GrapeResource.class_name_prefix %>::<%= name.camelize.pluralize %>::Entities::<%= name.camelize.singularize %>
end
desc "Delete"
params do
requires :id, type: String