Skip to content

Instantly share code, notes, and snippets.

@dstarh
Created May 29, 2014 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstarh/21609c738b52c11f94e2 to your computer and use it in GitHub Desktop.
Save dstarh/21609c738b52c11f94e2 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
@@page_title = nil
def self.set_title(page_title)
@@page_title = page_title
end
def page_title
ignore_for = %w{sessions devise}
if !ignore_for.include?(params[:controller]) && @@page_title.nil?
raise "set_title must be set for #{params[:controller]}##{params[:action]}"
end
@@page_title
end
helper_method :page_title
end
class ShoppingListController < ApplicationController
before_action :authenticate_user!
set_title "Shopping List"
def index
....
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment