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

Subclasses and Rabl

I have a feed that contains both parent and subclass objects, which i render using RABL into json. I include the root object in the json. The thing is this => depending on what comes first, the root node in the json will be generated with the…
meow
  • 27,476
  • 33
  • 116
  • 177
2
votes
1 answer

Image url in JSON (RABL, Dragonfly, Ruby on Rails)

I'm using RABL gem, my user model has many posts users/show.rabl object @user attributes :id, :name child :posts do extends "posts/post" end posts/_post.rabl attributes :id, image: post.image.url I want to show post's image,…
Bennington
  • 295
  • 4
  • 13
2
votes
1 answer

Reducing DB calls when using RABL with mongoid

I have a few scenarios where I would like to do as little DB calls as much as possible via eager loading, but I have not been able to do it well. Given the 2 scenarios below, how can i change my RABL to do as little calls as possible? OBJECT…
meow
  • 27,476
  • 33
  • 116
  • 177
2
votes
1 answer

How to use rabl with mustache and ruby on rails

I am using ruby 1.9.3p125 and rails 3.2.8 and added rabl to my gemfile today, so it should be up to date. I have used RABL in a simple situation where I wanted the json sent directly to the requester. Now I have a situation in which I want to use…
Anita Graham
  • 456
  • 1
  • 5
  • 13
2
votes
2 answers

convert Rabl to Erb json view

I am trying to convert this .json.rabl view to .json.erb and since im very new to ruby, I am looking for direction in achieving this. What will be the best way to go about this? object @perform attributes :id => :team_id attributes…
xoail
  • 2,978
  • 5
  • 36
  • 70
2
votes
1 answer

RABL renders ActiveRecord timestamps or datetimes as numbers instead of strings

I'm currently in the process of switching from ActiveRecord's as_json to RABL for API generation. as_json has been rendering timestamps in my models as strings of the format 2012-09-16T22:14:11+00:00. However, when I switched to RABL timestamps…
kevboh
  • 5,207
  • 5
  • 38
  • 54
2
votes
1 answer

Rails 3.2.8 + FactoryGirl + RABL: Differences on how datetime are returned

I have the following factory: FactoryGirl.define do factory :location do |f| f.descrizione { Faker::Company.name } f.indirizzo { 'Yellow submarine lane, 1'} f.citta { 'Nowhereland' } f.cap { '0100' } f.provincia { 'ZZ' } …
CarmineM74
  • 299
  • 2
  • 11
2
votes
1 answer

How to camelize ActiveRecord attributes to JSON respond?

Somebody have an idea? I have tried to find this option in Rabl Gem, but my searches have been unsuccessful. I think this is quite a common action and look forward to an early reply. Thanks!
extern.fx
  • 643
  • 1
  • 5
  • 9
2
votes
1 answer

rspec-rails + rabl rendering views even if I don't want them to be rendered?

I'm using rabl 0.6.13, rspec-rails 2.10.1, and rails 3.2.6. I'm trying to spec my controllers in isolation, but for some reason my rabl templates are throwing me all sorts of undefined method exceptions on the mocks I use in my controller specs. I…
Aaron Gibralter
  • 4,773
  • 3
  • 35
  • 50
2
votes
1 answer

How can I pass an object to rabl views from rake task

I am trying to create a json file from a rake task using rabl. Below I have the simplified version to test with. When I view 'articles.json' or 'articles/2.json' via the url, I get the expected json response. But when I try to run it via the rake…
Aaron Thomas
  • 505
  • 1
  • 6
  • 18
2
votes
1 answer

Multiple Child Models and Nesting RABL -- Works in HTML

I'm trying to use RABL to build JSON output for the following index.html.erb file: <% @halls.each do |hall| %> <%= hall.name.capitalize %>

<% hall.days.each do |day| %> <%= day.date.capitalize %>

<% day.meals.each do…
AlexSBerman
  • 37
  • 1
  • 5
2
votes
2 answers

Rails RABL respond_with error template

Using RABL in Rails 3.2.x, given the following controller action: respond_to :html, :json def create @foo = Foo.create(params[:foo]) respond_with @foo end Assuming the validation fails, how do you get respond_with to use a RABL template…
Andrew
  • 42,517
  • 51
  • 181
  • 281
2
votes
3 answers

Rabl, remove parent element of children

could anyone help me get rid of the "item" element within "items the output should be: "list":{ "items":[ { { data1: "test" } , { data2: "test2" } } } collection @list child :items => :items do attributes :place_id end child :items do child…
user896715
  • 101
  • 1
  • 6
1
vote
1 answer

API with rails 3.2 and rabl

I'm developing an API with rails 3.2 and rabl. Basically I have a model "Asset", and a very simple associated controller: class AssetsController < ApplicationController respond_to :json # GET /assets.json def index @assets =…
Luc
  • 16,604
  • 34
  • 121
  • 183
1
vote
1 answer

Create custom child node with RABL

I'd like to create JSON like this: { "field1": "value-1", "field2": "value-2", "actions": { "edit": "/edit/action/url" } } using rabl. It doesn't work with child method nor i can't do it with node - got unknown method error. So, is it…
NilColor
  • 3,462
  • 3
  • 30
  • 44