Questions tagged [rabl]

RABL (Ruby API Builder Language) is a Ruby templating system for generating XML and JSON.

RABL (Ruby API Builder Language) is a Ruby templating system for generating XML and JSON.

294 questions
4
votes
1 answer

RABL - Render collection as object with the ids as keys

In Ruby on Rails 4, I'm trying to make an API for my website and instead of using an array like so: [{id: 1, name: "John"}, {id: 2, name: "Foo"}, {id: 3, name: "Bar"}] I want to render it like this, because it makes it much easier to search through…
hansottowirtz
  • 664
  • 1
  • 6
  • 16
4
votes
1 answer

setup rails-api gem with rabl-rails

Im trying to use the rabl templating system from within rails-api. rabl looks for templates in the view path, which rails-api omits. How would i setup rabl-rails, i have included the below lines into my Controller. include…
theog
  • 2,062
  • 2
  • 14
  • 13
4
votes
2 answers

Cache warming with RABL for JSON templates

Okay, this post is a bit wordy before I got to the actual question, so the abridged version basically pertains to cache warming using RABL templates. When calling Rabl.render vs API calls, the caches generated do not have the same cache-keys. When…
blotto
  • 3,387
  • 1
  • 19
  • 19
4
votes
3 answers

Render simple JSON array with RABL in Rails

I've been trying to figure out how to make RABL render a very simple JSON array of string, such as: ["my,"array","of","strings"] The controller would be class StringsController < ApplicationController responds_to :json def index …
neill
  • 90
  • 1
  • 7
4
votes
2 answers

Render Facebook friends with 'registered' attribute

Basycally what I would like to do is to : Get the Facebook friends of a the current user Render this collection while differentiating user who are already registered with my app to other users by adding a 'registered' attribute set to true or false…
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
4
votes
3 answers

Rabl caching with nested object

Here are my rabl views: students/show.json.rabl object @student cache @student attribute :name, :gender, :age node :school do |student| partial("shared/school", :object => student.school) end shared/_school.json.rabl object @school cache…
ankimal
  • 915
  • 3
  • 9
  • 22
4
votes
0 answers

RABL vs Json Builder

As part of a team, we are building an RoR application completely driven through API's. We already have a web app, its just that we now want to make it completely API driven. We initially kicked off with using RABL Templating Engine for generating…
boddhisattva
  • 6,908
  • 11
  • 48
  • 72
4
votes
2 answers

How can I get sencha architect to read json from rails

I have a Ruby on Rails 3 news app. It takes a title, some content and an image attachment (using the paperclip gem). I'm using the RABL gem to provided a Sencha Architect project with a JSON feed. The problem is Sencha Architect can't read the JSON…
Craig Walsh
  • 117
  • 8
4
votes
1 answer

Rails 3 API with RABL

I am trying to use RABL to create an API - but my setup is a bit different than the standard setup - as defined in their WIKI. I have setup an API namespace in my routes: namespace :api do resources :orders end I have my controller within…
Paul
  • 401
  • 5
  • 16
4
votes
2 answers

Passing arbitrary options to rabl partial/extend

Is it possible to pass options other than the object into a rabl partial? For example, the parent template passes an option called "show_field1" to the base template: extends "base", :show_field1 => true Then in base.rabl the option could be used…
4
votes
1 answer

Rabl json collection dynamic keys

I have a User model that has many posts. Im trying to render the post in a rabl collection. collection @posts attributes :title, :created_at The default rabl format for rendering json collections is {'posts': ['post':{}, 'post':{}]} . What I'm…
pkurek
  • 606
  • 4
  • 13
4
votes
4 answers

Accessing the child instance in a RABL template

I have a RABL template as shown below object @user attributes :name child :contacts do # does not work if contact.is_foo? attributes :a1, :a2 else attributes :a3, :a4 end end How do I access the Contact object in the child block of…
Harish Shetty
  • 64,083
  • 21
  • 152
  • 198
3
votes
0 answers

Rails + RABL custom dynamic keys

Is it possbile with RABL to set the key names dynamically? I am trying to out put in the following format... snippet_1: {name: 'map', options: {'options[postcode]': "SW64TY"}}, snippet_2: {name: 'map', options: {'options[postcode]': "GU78YU"}} and…
nodrog
  • 3,532
  • 2
  • 25
  • 31
3
votes
3 answers

Rails 3 respond_with: show "show" layout on resource creation

I've got a comment resource. I've got a controller that handles respond_with, and for right now, it's supposed to be serving up all JSON responses (which is happening correctly). I'm using Rabl to handle my JSON/XML rendering, and I'm DRY-ing things…
Ben Kreeger
  • 6,355
  • 2
  • 38
  • 53
3
votes
1 answer

RABL and XML formatting

I'm using RABL to format the output of a Rails API I'm creating. Is there anyway to customize the shape of the XML being produced? For instance, I need to produce an output that uses XML attributes, instead of elements. In other words, this...
Claudio Lassala
  • 271
  • 3
  • 15
1 2
3
19 20