Coder Social home page Coder Social logo

Comments (10)

onethirtyfive avatar onethirtyfive commented on May 30, 2024

I did some work on this

from grape.

amrnt avatar amrnt commented on May 30, 2024

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

from grape.

onethirtyfive avatar onethirtyfive commented on May 30, 2024

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. :)

from grape.

amrnt avatar amrnt commented on May 30, 2024

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 { }

from grape.

onethirtyfive avatar onethirtyfive commented on May 30, 2024

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.

from grape.

amrnt avatar amrnt commented on May 30, 2024

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://github.com/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

from grape.

fbernier avatar fbernier commented on May 30, 2024

+1

from grape.

kvirani avatar kvirani commented on May 30, 2024

+1

from grape.

LTe avatar LTe commented on May 30, 2024

https://github.com/LTe/grape-rabl

from grape.

dblock avatar dblock commented on May 30, 2024

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!

from grape.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.