yılında Raylar 2.3 hep önyüz için JSON veri göndermek için Raylar JSON enjeksiyon
render :json => { :success => true, :data => @foobar}
kullandı. Raylar 3 ben
respond_to :json
...
respond_with @foobar
kullanıyorum Ama ben eksik: Ben JSON yapısı içinde 'başarı' değerini gerekir. Rails 3'teki JSON yanıtına bu tür verileri enjekte etmenin doğru yolu nedir?
Hm de bu çalıştım, ama sonuç olarak aşağıdaki hatayı alıyorum:
SyntaxError (app/controllers/properties_controller.rb:13: syntax error, unexpected tASSOC, expecting '}'
respond_with { :success => true, :data => @property }
^
/app/controllers/properties_controller.rb:13: Can't assign to true
respond_with { :success => true, :data => @property }
^
app/controllers/properties_controller.rb:13: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
respond_with { :success => true, :data => @property }
Hmhm, bunu da denedim, ancak aşağıdaki gibi bir hatayı alıyorum: – ctp