Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of views or at least "rabl" #44

Closed
amrnt opened this issue Jul 21, 2011 · 10 comments
Closed

Add support of views or at least "rabl" #44

amrnt opened this issue Jul 21, 2011 · 10 comments

Comments

@amrnt
Copy link

amrnt commented Jul 21, 2011

No description provided.

@onethirtyfive
Copy link

I did some work on this

@amrnt
Copy link
Author

amrnt commented Aug 2, 2011

I tried you branch, but I don't know why it didnt work. always returns { }

@onethirtyfive
Copy link

Did you initialize rabl per its instructions? All my patch does is get tilt in the stack. You'll still need to do RABL.initialize! (or whatever RABL requires, I don't recall) after your bundled gems are loaded, but before you 'run' your api. Give it a shot in config.ru?

Also, because the current implementation is pretty naive, you'll need to render by local variables, as detailed in the example. :)

@amrnt
Copy link
Author

amrnt commented Aug 2, 2011

Rabl need to be Rabl.register!.

resource :me do
  get do
    template 'user.rabl'
    { :user => current_user }
  end
end

In the same folder user.rabl

object user

attributes :_id, :display_name

Again when I go to /me All I get { }

@onethirtyfive
Copy link

Hi amrnt,

I committed some changes for some simple mistakes I made. I also made an example repository illustrating how this works after my changes.

@amrnt
Copy link
Author

amrnt commented Aug 3, 2011

progress going awesome! Thanks @onethirtyfive.

But there's an issue, (I have 7 items. And I want to How to output some random, not directly related items https:/nesquena/rabl/wiki/Tips-and-tricks)

object false

child(@object) do
  attributes :_id, :caption, :created_at
end

node(:pagination, :unless => @object.blank?) do
  {
    :next => @object.next_page,
    :previous => @object.previous_page,
    :total_pages => @object.total_pages,
    :current_page =>  @object.current_page,
  }
end

returns

[
  { }
  { }
  { }
  { }
  { }
  { }
  { }
]

Though, it works fine with sinatra/rails

@fbernier
Copy link

fbernier commented Dec 1, 2011

+1

1 similar comment
@kvirani
Copy link

kvirani commented Dec 21, 2011

+1

@LTe
Copy link
Member

LTe commented Jan 10, 2012

https:/LTe/grape-rabl

@dblock
Copy link
Member

dblock commented Dec 17, 2012

The next release of Grape has cleaner support for other formatters. I made a pull request into grape/rabl using the new syntax here: ruby-grape/grape-rabl#6.

This is what the user has to do:

formatter :json, Grape::Formatter::Rabl

Hope to see a lot more formatters our there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants