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
6
votes
1 answer

Conditionally include child nodes with RABL

I think I have a very basic case when I'm using rabl to return JSON for standard RESTful controller methods... First let's say I have a typical one to many relationship with parent and child (let's say customer and accounts): class Customer <…
6
votes
2 answers

Rails rabl - returning ALL attributes, not just named ones

Rabl allows you to grab the attributes by naming them in your view, for instance: object @user attributes :name, :email I have a model whose attributes are will not be known, but I'd like to display everything returned from the controller in my…
Squadrons
  • 2,467
  • 5
  • 25
  • 36
6
votes
1 answer

HAML prevents template engines to render anything else than HTML

I am using Jbuilder (and I also tried to use Rabl) to render json. When I try to render the jbuilder template in my application it renders the template within the layouts/application file and returns HTML as JSON (see line 'within…
Flov
  • 1,527
  • 16
  • 25
5
votes
1 answer

Rails 3.1 deep nesting with RABL

I'm using the RABL gem to render JSON user data for users of comments which are children of annotations which are children of images. I'd like to do something similar to: object @image node :annotations do @image.annotations.map { |a| { :id…
ramz15
  • 2,351
  • 3
  • 18
  • 22
5
votes
2 answers

RABL: change default date and time format to iso8601

I'm using rabl 0.11.6 for my API, and I find myself doing the following over and over again for every date or time object: node :created_at do |article| article.created_at.iso8601 end It would save a lot of code duplication, if the format for…
23tux
  • 14,104
  • 15
  • 88
  • 187
5
votes
1 answer

Empty response when rendering RABL template with RSPEC

I'm having a perplexing problem where my controller is working fine. However, when I'm testing it with RSPEC it's returning an empty string as the response body. Here is the controller: class Api::UsersController < Api::ApplicationController def…
5
votes
2 answers

Having issues with Access-Control-Allow-Origin

I have a Rails app running in Heroku, and a html file using Jquery Mobile. The Rails app returns JSON data (using RABL), that my mobile app is suppose to pick up and show. This is what I'm doing, I'm feeding the contents of the response to a…
Sebastialonso
  • 1,437
  • 18
  • 34
5
votes
2 answers

Rails RABL if else statement

I'm using RABL in a Rails app to access data via REST. It's working except for the if statement. I get this error: undefined local variable or method `matitem_id' This is my show.json.rabl code: object @expense attributes :id, :unitcost,…
Reddirt
  • 5,913
  • 9
  • 48
  • 126
5
votes
2 answers

RABL API Views Directory?

I really like RABL, but it's seeming like it's going to clutter up my views folders with .rabl files. I really want to ideally have a seperate API views directory so it would be like this: app/ views/ customers/ …
andy
  • 2,369
  • 2
  • 31
  • 50
5
votes
1 answer

Incomplete response body being returned from Rails 3 app with RABL

I've built a JSON API using Rails 3 and RABL The API works well but on particular requests only part of the data is returned - the rest of the JSON is cut off. Since the JSON is therefore invalid, the mobile app which relies on the API is…
bodacious
  • 6,608
  • 9
  • 45
  • 74
5
votes
1 answer

Render ERB Template in RABL Template

I have a scenario where I'd like to pass back a long message with my JSON. Instead of writing it out with string concatenation I'd rather put together an erb template that I can render into my JSON. Below is the code I'm currently trying: object…
jachenry
  • 137
  • 1
  • 10
5
votes
1 answer

Using rabl and a collection, having trouble adding additional child node

I have a collection of articles I want to show in my json response. I would also like to export a node about the type of json request asked. index.json.rabl collection @articles => :headlines extends 'articles/show' show.json.rabl object…
Aaron Thomas
  • 505
  • 1
  • 6
  • 18
5
votes
2 answers

How to improve performance of single-page application?

Introduction I have a (mostly) single-page application built with BackboneJS and a Rails backend. Because most of the interaction happens on one page of the webapp, when the user first visits the page I basically have to pull a ton of information…
David Tuite
  • 22,258
  • 25
  • 106
  • 176
5
votes
2 answers

Using RABL with Draper to render to_json

I've got some fairly complex JSON responses in my application for my Ticket model and I'd like my TicketDecorator to be the one who builds those responses. However, I've already setup and API for my system and use RABL to build those JSON responses,…
TheDelChop
  • 7,938
  • 4
  • 48
  • 70
4
votes
1 answer

Rendering partials in rabl

I am using RABL to format the output of a Rails API. I tried following code message.rabl: object @message attributes :id,:description,:created_at,:created_by_user_id child @comments do |t| partial("user/comment", :object =>…
nilkash
  • 7,408
  • 32
  • 99
  • 176
1
2
3
19 20