Skip to content

Instantly share code, notes, and snippets.

@dgorodnichy
Created May 10, 2020 18:48
Show Gist options
  • Save dgorodnichy/a8aa3f1307204a28b42de4b1c666f910 to your computer and use it in GitHub Desktop.
Save dgorodnichy/a8aa3f1307204a28b42de4b1c666f910 to your computer and use it in GitHub Desktop.
class FilmsController < ApplicationController
def index
@films = serialized_films
render json: @films
end
def serialized_films
Film.all.map do |film|
{
title: film.title,
genre: film.genre,
rate: film.avg_rating
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment