You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Mysite
module Entities
class V1::Order < Mysite::Entities::Base
expose :id
expose :state
expose :cost
expose :supplier, using: "Mysite::Entities::V1::Supplier"
expose :office, using: "Mysite::Entities::V1::TheOffice", as: :customer
expose :order_product_memberships, using: "Mysite::Entities::V1::OrderProductMembership", as: :product
with_options(format_with: :iso_timestamp) do
expose :created_at
expose :updated_at
end
end
end
end
app/api/mysite/v1/order_api.rb
module Mysite
class V1::OrderAPI < Mysite::API
resource :orders do
include Grape::Kaminari
paginate per_page: 20
desc "Return a list of orders"
params do
requires :api_key
requires :company_role
optional :last_time_seen, allow_blank: false
end
get do
company = Company.find_by_api_key!(params[:api_key])
orders = company.orders_as(params[:company_role]).updated_from(params[:last_time_seen])
present :orders, paginate(orders), with: Mysite::Entities::V1::Order
end
...
When I trying to get list of orders via api, I get:
RuntimeError (Circular dependency detected while autoloading constant Mysite::Entities::V1::Order):
app/api/mysite/v1/order_api.rb:16:in `block (2 levels) in <class:OrderAPI>'
(in "present :orders...")
Early I have similar problem with expose :office, using: Mysite::Entities::V1::TheOffice, as: :customer
unless when I moved Mysite::Entities::V1::TheOffice in quotes
Now problem with with: Mysite::Entities::V1::Order
I have tried many tricks and I think it's a bug.
Just a sidenote to and old issue: There's now an ability in grape-entity to define the class name as a string. This will help with circular dependencies:
app/api/mysite/entities/v1/order.rb
app/api/mysite/v1/order_api.rb
When I trying to get list of orders via api, I get:
(in "present :orders...")
Early I have similar problem with
expose :office, using: Mysite::Entities::V1::TheOffice, as: :customer
unless when I moved Mysite::Entities::V1::TheOffice in quotes
Now problem with
with: Mysite::Entities::V1::Order
I have tried many tricks and I think it's a bug.
ruby 2.1.1
rails 4.1.8
grape (0.13.0)
grape-entity (0.4.5)
The text was updated successfully, but these errors were encountered: