Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rails_current

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_current

  • 2.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

rails_current

DESCRIPTION

track current_user et all in a tidy, global, and thread-safe fashion.

SYNOPSIS

most rails apps scatter a bunch of @current_foobar vars everywhere. don't do that. it's fugly. instead, do this.

declare the current_XXX variables you'll want tracked. you can pass a block for lazy computation

class ApplicationController

  Current(:user){ User.find session[:current_user }
  Current(:account)

end

you can now access the current state two ways

  • globally from anywhere in your code base
    if Current.user
    
      ...
    
    end
    
    Current.user = User.find(id)
    
  • using the current_ methods that are added by including the Current module into any class (ActionController::Base and ActionView::Base automatically include it)
    if current_user
    
      ...
    
    end
    
    self.current_user = User.find(id)
    

the Current module is cleared out before every request and is thread safe.

INSTALL

gem install rails_current


gem 'rails-current', :require => 'current'

bundle install

FAQs

Package last updated on 23 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc