mel C
mel C

Reputation: 19

Grape with rails: model name conflict or not found

When I create an API service for my rails app I get a problem. The API is below:

module API class Level < Grape::API resources :levels do get do Level.all end end end end

and I also created a model named level

class Level < ActiveRecord::Base some methods end

when I request the API interface

undefined method `all' for API::Level:Class

so what should I do, I change the Level.all to ::Level.all it worked,but it's not good for me.

Upvotes: 0

Views: 510

Answers (1)

infused
infused

Reputation: 24347

This is by design. You are basically disambiguating the class name.

Upvotes: 1

Related Questions