ruby-grape / grape-rabl

Use rabl with grape
MIT License
136 stars 29 forks source link

Template for Resource #8

Closed ichilton closed 11 years ago

ichilton commented 11 years ago

It would be good if you could supply the :rabl option to a resource.

For example, instead of:

resource 'articles' do
  get '/', :rabl => "article" do
    @article = Article.all
  end

  get ':id', :rabl => "article" do
    @article = Article.find(params[:id])
  end
end

You could do:

resource 'articles', :rabl => "article" do
  get do
    @article = Article.all
  end

  get ':id' do
    @article = Article.find(params[:id])
  end
end

Thanks,

Ian

LTe commented 11 years ago

resource method is alias for namespace

In grape:

def namespace(space = nil, &block)
  # code
end

No we can not pass options argument to resource method. But, but :) You can do a trick

class MyApi < Grape::API
  desc "my_desc", :rabl => "user"
  resource "user" do
    get("/") # == get("/", :rabl => "user")
  end

But for you information, this issue is related to grape