Skip to content

Instantly share code, notes, and snippets.

@phensalves
Last active December 2, 2016 14:32
Show Gist options
  • Save phensalves/db58c1ad3318dfadb142deefa0c87780 to your computer and use it in GitHub Desktop.
Save phensalves/db58c1ad3318dfadb142deefa0c87780 to your computer and use it in GitHub Desktop.
class Marvel::CharactersController < ApplicationController
before_action :authenticate_user!
def index
@characters = Character.paginate(page: params[:page], per_page: 10)
get_all_characters unless @characters.present?
end
def show
@character = get_character
get_all_character_comics unless @character.comics.present?
end
private
def get_character
Character.friendly.find(params[:id])
end
def character_params
params.fetch(:character, {})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment