Skip to content

Instantly share code, notes, and snippets.

@dgorodnichy
Last active May 10, 2020 19:25
Show Gist options
  • Save dgorodnichy/3f05f59461c6563575d98ca5e061c4da to your computer and use it in GitHub Desktop.
Save dgorodnichy/3f05f59461c6563575d98ca5e061c4da to your computer and use it in GitHub Desktop.
class FilmsController < ApplicationController
def index
@films = serialized_films
render json: @films
end
private
def films_scope
Film.all
end
def serialized_films
FilmCarrier.wrap(films_scope).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