StoreCurrentUser
Uses the RequestStore gem to save a reference to the current_user for each request.
Installation
Add this line to your application's Gemfile:
gem 'store_current_user'
And then execute:
$ bundle
Or install it yourself as:
$ gem install store_current_user
Usage
Adds methods .current and .current= to the User model. Provides a controller before_filter to save the user to the RequestStore.
Add this line:
class ApplicationController < ActionController::Base
stores_current_user
end
Now you can use User.current almost anywhere in your app.
Contributing
- Fork it ( https://github.com/[my-github-username]/store_current_user/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request