Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Cannot alias collection attribute #283

centaure opened this Issue · 4 comments

2 participants

centaure David Sommers

My Rabl file was:

collection @tags
attributes :id, :name

The above worked fine. For example, running curl gave me:

centaur@ubuntu:~$ curl http://localhost:3000/api/videos/1/tags.json

However, when I attempted to alias the second attribute, as shown below, it does not return me the attribute I attempted to alias:

collection @tags
attributes :id, :name => :foo

centaur@ubuntu:~$ curl http://localhost:3000/api/videos/1/tags.json

And if I move the aliased attribute to be the first as shown below, I get a bunch of errors thrown (errors are attached at the end of this mail):

collection @tags
attributes :name => :foo, :id

What am i doing wrong here?

(note the following is just the beginning of the error trace).

centaur@ubuntu:~$ curl http://localhost:3000/api/videos/1/tags.json
<!DOCTYPE html>

Action Controller: Exception caught
<br> body { background-color: #fff; color: #333; }</p> <pre><code>body, p, ol, ul, td { font-family: helvetica, verdana, arial, sans-serif; font-size: 13px; line-height: 18px; } pre { background-color: #eee; padding: 10px; font-size: 11px; } a { color: #000; } a:visited { color: #666; } a:hover { color: #fff; background-color:#000; } </code></pre> <p>

SyntaxError in Videos#tags

Showing /home/centaur/Documents/fungus_mock1/fungus/fungus/copper/app/views/videos/tags.json.rabl where line #1 raised:

(eval):2:in `render': compile error
(eval):2: syntax error, unexpected '\n', expecting tASSOC

Extracted source (around line #1):

1: collection @tags
2:   attributes :name => :foo, :id


I have the same problem when I deal with a model. The following will not return me the second attribute (:tag_name_id) if I attempt to alias it as "attributes :name, :tag_name_id => :id".

object @tag

attributes :name, :tag_name_id

David Sommers

Aliased hashes have to go on a separate line. This will work:

collection @tags

attributes :id, :something_else
attributes :name => :foo

Thanks databyte, that works!

Maybe it would be a good idea to clarify this in the documentation (

So aliasing both attributes within one "attributes" method call (i.e. "attributes id: => :foo_id, :name => :foo"), works (just like in the documentation example above "attributes :bar => :baz, :dog => :animal"). But having one aliased attribute + one non-aliased attribute within one "attributes" method call throws errors (e.g. "attributes :bar => :baz, :dog") . This is not clarified in, and I spent a couple of hrs debugging this to no avail.

Thanks a lot for the help databyte!

David Sommers

Done - thanks.

David Sommers databyte closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.