Created
November 20, 2017 10:32
-
-
Save bernardobarreto/b021285269b2b09a69d30efe39b72c94 to your computer and use it in GitHub Desktop.
rails controller concern example
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
module IncrementableVisits | |
extend ActiveSupport::Concern | |
included do | |
before_action :increment_visits, only: [:index, :show, :new, :edit] | |
end | |
def increment_visits | |
current_user.inc(visits: 1) # Mongoid ODM example | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment