Skip to content

Instantly share code, notes, and snippets.

@elskwid
Created February 21, 2014 07:02
Show Gist options
  • Save elskwid/9129980 to your computer and use it in GitHub Desktop.
Save elskwid/9129980 to your computer and use it in GitHub Desktop.
Use a concern in a Controller
Started GET "/" for 127.0.0.1 at 2014-02-20 22:43:21 -0800
Processing by WebsiteController#index as HTML
Rendered text template (0.0ms)
Completed 200 OK in 2.3ms (Views: 1.9ms | ActiveRecord: 0.0ms)
some_method from shared logic
some_method from overridden in website controller
module SharedControllerLogic
extend ActiveSupport::Concern
included do
before_filter :some_method
end
def some_method
puts "some_method from shared logic"
end
end
class WebsiteController < ApplicationController
include SharedControllerLogic
def index
render text: "hello world"
end
def some_method
super
puts "some_method from overridden in website controller"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment