In Rails 2.3 Früher habe ich immerRails JSON Injektion
render :json => { :success => true, :data => @foobar}
JSON-Daten zu meinem Frontend zu senden. In Rails 3 Ich bin mit
respond_to :json
...
respond_with @foobar
Aber was mir fehlt: Ich brauche den ‚Erfolg‘ Wert innerhalb der JSON-Struktur. Was ist der richtige Weg, um solche Daten in Rails 3 in die JSON-Antwort zu injizieren?
Hm, versuchte auch, aber ich erhalte die folgende Störung als Ergebnis:
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, versuchte dies auch, aber ich bekomme den folgenden Fehler als Ergebnis: – ctp