Skip to content

Instantly share code, notes, and snippets.

@betzerra
Last active April 21, 2017 05:34
Show Gist options
  • Save betzerra/7da4c5709c4f45edca3912e2875197ca to your computer and use it in GitHub Desktop.
Save betzerra/7da4c5709c4f45edca3912e2875197ca to your computer and use it in GitHub Desktop.
Any idea how to write this better?
Reaction.joins(:news).where(user: user).as_json(include: :news).to_json
[{
"reaction_id": 20,
"reaction": ":no_mouth:",
"user_id": 8,
"news_id": 132219,
"news": {
"news_id": 132219,
"url": "http://www.lanacion.com.ar/2007070-mar-del-plata-impactantes-imagenes-del-temporal-que-afecta-a-la-ciudad",
"title": "Mar del Plata: impactantes imágenes del temporal que afecta a la ciudad",
"date": 1491693345,
"source_id": 3,
"img_url": "http://bucket.glanacion.com/anexos/fotos/13/2415513.jpg"
}
}, {
"reaction_id": 21,
"reaction": ":scream:",
"user_id": 8,
"news_id": 132219,
"news": {
"news_id": 132219,
"url": "http://www.lanacion.com.ar/2007070-mar-del-plata-impactantes-imagenes-del-temporal-que-afecta-a-la-ciudad",
"title": "Mar del Plata: impactantes imágenes del temporal que afecta a la ciudad",
"date": 1491693345,
"source_id": 3,
"img_url": "http://bucket.glanacion.com/anexos/fotos/13/2415513.jpg"
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment