2016-04-06 6 views
0

私はgrape-entityを使用しようとしていますが、私のエンティティクラスの名前空間に問題がありますが、なぜその理由がわかりません。無効な定数API ::ブドウとブドウのエンティティ

私はこのブドウエンティティクラスを持っている:

# app/controllers/api/v1/entities/vehicules.rb 
module API 
    module V1 
    module Entities 
     class Vehicules < Grape::Entity 
     expose :marque 
     expose :modele 
     expose :user do 
      expose :name 
     end 
     end 
    end 
    end 
end 

そしてブドウクラス:

# app/controllers/api/v1/vehicules.rb 
module API 
    module V1 
    class Vehicules < Grape::API 
     include API::V1::Defaults 
     version 'v1' 
     format :json 


     resource :vehicules do 
     desc "Return list of vehicules" 
      get do 
      #authenticate! @todo 
      vehicules = Vehicule.find_by(user_id: params['user_id']) 
      present vehicules, with API::V1::Entities::Vehicules 
      end 

私はcurl http://localhost:3000/api/v1/vehicules?user_id=123を呼び出すと、私はレールのサーバにこのメッセージを持っている:

Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:457:in `load': 
app/controllers/api/v1/vehicules.rb:21: syntax error, unexpected tCONSTANT, expecting keyword_do or '{' or (' SyntaxError) 
present vehicules, with API::V1::Entities::Vehicules 
         ^

どんな助けも素晴らしいでしょう。

答えて

0

それはwith:

present vehicules, with: API::V1::Entities::Vehicules 
です
関連する問題