Question

Je veux rendre un simple JSON à partir d'un tableau.

array = ["valueid",true]
render :json=>array

qui revient:

{"json":["valueid",true]}

Mais je ne veux pas du JSON. La seule partie que je veux est:

["valueid",true]

Y a-t-il un moyen simple?

Était-ce utile?

La solution

Ouais:

get :index do
  [:id, 4].to_json
end

Meilleur:

get :index, :provides => :json do
   my_array.to_json
end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top