Last active
May 15, 2018 17:42
-
-
Save gosukiwi/d7f51ca730f255aecb842a87cb81efb2 to your computer and use it in GitHub Desktop.
Helper Methods Module Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/books_controller.rb | |
class BooksController < ApplicationController | |
include HelperMethods::BooksController | |
def index; end | |
def show; end | |
end | |
# app/controllers/helper_methods/books_controller.rb | |
module HelperMethods | |
module BooksController | |
helper_methods :books, :book | |
def books | |
Book.active | |
end | |
def book | |
Book.find(params[:id]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment