Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

collection helper bug?

1 view
Skip to first unread message

SMiX

unread,
Nov 26, 2010, 6:23:36 AM11/26/10
to restfulie
I have found out that `collection` helper does not adds `type="array"`
attribute to the xml tag and after parsing client mistakenly thiks
that my data is a Hash but must be array. Here is an example:

https://gist.github.com/716580

The probles is partially resolving by using respond_to without
template but it is very bad to show passwords hashes to api users.

Guilherme Silveira

unread,
Nov 26, 2010, 9:40:22 AM11/26/10
to rest...@googlegroups.com
Hi there,

You are right, by default Restfulie + Tokamak is not adding the
type="array" when rendering an array in order to be Rails-agnostic (a
resource representation should not depend on Rails's standards to be
understood: the type="array" is a Rails thing, not a xml one).
But as you mentioned it does not help if you are using it on the client side.

We can change this behavior by updating the members method here:
https://github.com/caelum/restfulie/blob/master/lib/restfulie/common/converter/xml/builder.rb

So the members method would attach a type="array" attribute, what do you think?

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

SMiX

unread,
Dec 6, 2010, 9:24:22 AM12/6/10
to restfulie
I think both `collection` and `members` methods must accept hash
params like `member` method for ability to define tag attributes like
<object attr="val">
What do you think?

On 26 ноя, 17:40, Guilherme Silveira
<guilherme.silve...@caelum.com.br> wrote:
> Hi there,
>
> You are right, by default Restfulie + Tokamak is not adding the
> type="array" when rendering an array in order to be Rails-agnostic (a
> resource representation should not depend on Rails's standards to be
> understood: the type="array" is a Rails thing, not a xml one).
> But as you mentioned it does not help if you are using it on the client side.
>
> We can change this behavior by updating the members method here:https://github.com/caelum/restfulie/blob/master/lib/restfulie/common/...
>
> So the members method would attach a type="array" attribute, what do you think?
>
> Regards
>
> Guilherme Silveira
> Caelum | Ensino e Inovaçãohttp://www.caelum.com.br/

Guilherme Silveira

unread,
Dec 8, 2010, 8:37:44 AM12/8/10
to rest...@googlegroups.com
Hello,

Sure. It makes sense, do you want to suggest a way to invoke the
method? We can do it. Only for xml based representations ? Does it
make sense for json?

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Reply all
Reply to author
Forward
0 new messages