Skip to content

Instantly share code, notes, and snippets.

@gosukiwi
Last active May 15, 2018 17:42
Show Gist options
  • Save gosukiwi/d7f51ca730f255aecb842a87cb81efb2 to your computer and use it in GitHub Desktop.
Save gosukiwi/d7f51ca730f255aecb842a87cb81efb2 to your computer and use it in GitHub Desktop.
Helper Methods Module Pattern
# 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