LTe/grape-rabl — Issue #1: How to use with Rails?
Author: TheOddLinguist
Created: 2012-02-27 01:10:51+00:00
State: open

I've got a Rails app in which I've built a simple API using grape. I'd like to use my existing RABL templates for this API, so I've stumbled upon this gem. I can't get it to function with my Rails app, though.

I've got my /app/api/api.rb setup like this:

require 'grape/rabl'

use Rack::Config do |env|
env['api.tilt.root'] = Rails.root.join('app', 'views')
end

class API < Grape::API
...

but that gives me this error:

app/api/api.rb:3:in `': undefined method `use' for main:Object (NoMethodError)

Any ideas what I'm doing wrong? Or perhaps this wasn't meant to work in a Rails environment? On a related note, you've got this in your README:

object @user => :user # in the RABL template

How does this work? I feel like updating all my RABL templates with lines like this might make other parts of my app that use the templates break; hence my thinking this won't work in a Rails app. ...but feel free to set me straight. hehe

Let me know if you need any other information.