Joined May 2014
·

Justin Schuhmann

United States
·
·

Posted to Make a painless web API in Ruby over 1 year ago

In my solution I have to do the following:

users = CloudUser.all
present :data, users, :with => CloudUser::Entity

After defining:

class CloudUser < ActiveRecord::Base
    self.primary_key = :username

    has_many :configurations, :class_name => 'Configuration'
    has_many :favorites, :class_name => 'Favorite', :foreign_key => :username

    class Entity < Grape::Entity
      expose :username, :email, :first_name, :last_name
    end
end

So it wasn't as easy as just defining a class Entity for me.

Achievements
29 Karma
0 Total ProTip Views
Interests & Skills