Description
Finds a subject by id
Tip
Override this method to add some custom logic to fetching process.
Used in
Use
Example
class BooksController < ApplicationController
include RestingPug::Base
private
# Override a fetch_subject to return a default subject if requested is not found
def fetch_subject
@subject = subject_model.find_by_id(params[:id]) || default_subject
end
end
Source code
# lib/resting_pug/subject.rb
def fetch_subject
@subject = subject_model.find(params[:id])
end