grape-entity

Inheriting class definition from parent class

隐身守侯 提交于 2019-12-24 18:35:39
问题 I am building Grape Entities inside my Rails models as described here: https://github.com/ruby-grape/grape-entity#entity-organization Currently I am creating default values automatically, based on the column hash of the model itself. So I have a static get_entity method that exposes all the model's columns: class ApplicationRecord < ActiveRecord::Base def self.get_entity(target) self.columns_hash.each do |name, column| target.expose name, documentation: { desc: "Col #{name} of #{self.to_s}" }

Grape error handling strategy?

非 Y 不嫁゛ 提交于 2019-12-10 03:36:44
问题 I am using Grape and Rails to create a REST API. I have the basic architecture in place and I am looking for places to 'clean' things up. One of those places is the error handling/processing. I am currently rescuing errors in the root.rb (GRAPE::API base class) file for the whole API. I format them and then send the error back via rack_response. Everything works find but the root.rb file is getting a bit bloated with all the errors being rescued and some of them have special parsing that

Grape error handling strategy?

让人想犯罪 __ 提交于 2019-12-05 04:06:32
I am using Grape and Rails to create a REST API. I have the basic architecture in place and I am looking for places to 'clean' things up. One of those places is the error handling/processing. I am currently rescuing errors in the root.rb (GRAPE::API base class) file for the whole API. I format them and then send the error back via rack_response. Everything works find but the root.rb file is getting a bit bloated with all the errors being rescued and some of them have special parsing that needs to be done. I was wondering if anyone has developed a good strategy for error handling so that it can