Why does trying to use Grape with Rails fail with “uninitialized constant API”?

前端 未结 3 458
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-16 04:21

I would like someone to explain why this is happening in Rails (4.1.8) with Grape (0.10.1)

so this is my API:

app/api/root.rb:

m         


        
3条回答
  •  死守一世寂寞
    2021-01-16 04:51

    From Grape's documentation:

    For Rails versions greater than 6.0.0.beta2, Zeitwerk autoloader is the default for CRuby. By default Zeitwerk inflects api as Api instead of API. To make our example work, you need to uncomment the lines at the bottom of config/initializers/inflections.rb, and add API as an acronym:

    ActiveSupport::Inflector.inflections(:en) do |inflect|
      inflect.acronym 'API'
    end
    

提交回复
热议问题