sixarm_ruby_current_user

SixArm.com » Ruby » Get the current user of a Ruby on Rails app

https://github.com/sixarm/sixarm_ruby_current_user

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.4%) to scientific vocabulary

Keywords

current-user gem rails ruby
Last synced: 4 months ago · JSON representation ·

Repository

SixArm.com » Ruby » Get the current user of a Ruby on Rails app

Basic Info
  • Host: GitHub
  • Owner: SixArm
  • License: other
  • Language: Ruby
  • Default Branch: main
  • Homepage: http://sixarm.com
  • Size: 326 KB
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
current-user gem rails ruby
Created about 15 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Codeowners

README.md

SixArm.com → Ruby →
CurrentUser module with current_user methods

Introduction

Get and set the current user in the Rails session array.

When you set the current user, this does: - @currentuser = user - @currentuserid = user.id - session[:currentuser_id] = user.id

For docs go to http://sixarm.com/sixarm_ruby_current_user/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_current_user

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_current_user'

Require

To require the gem in your code:

require 'sixarm_ruby_current_user'

Example code

joe = User.find(123)
self.current_user = joe
=>
@current_user == joe
@current_user_id == 123
session[:current_user_id] == 123

Example controller

class MyController < ApplicationController

  def sign_in(user)
    self.current_user = user
  end

  def sign_out
    self.current_user = nil
  end

  def is_anyone_using_this?
    current_user?
  end

end

Example of reloading

For fast speed, we memoize currentuser and currentuserid: we use fast instance variables @currentuser and @currentuserid rather than reading the slower session[:currentuserid] each time.

To reload @currentuser and @currentuserid from session[:currentuser_id], we use the :reload parameter like this:

current_user(:reload => true)

Why use the self prefix?

When we set variables, we must use the "self" prefix because Ruby uses this to do method dispatch.

Right:

self.current_user = joe

Wrong:

current_user = joe

Owner

  • Name: SixArm
  • Login: SixArm
  • Kind: organization
  • Email: sixarm@sixarm.com
  • Location: San Francisco

SixArm Software

Citation (CITATION.cff)

cff-version: 1.2.0
title: SixArm.com → Ruby → <br> CurrentUser module with current_user methods
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/SixArm/sixarm_ruby_current_user/'
    description: SixArm.com → Ruby → <br> CurrentUser module with current_user methods
repository-code: 'https://github.com/SixArm/sixarm_ruby_current_user/'
abstract: >-
  SixArm.com → Ruby → <br> CurrentUser module with current_user methods
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 90
  • Total Committers: 1
  • Avg Commits per committer: 90.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 90
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

sixarm_ruby_current_user.gemspec rubygems
  • minitest >= 5.7.0, < 6 development
  • rake > 10.4.2, < 11 development
  • simplecov >= 0.10.0, < 2 development
  • sixarm_ruby_minitest_extensions >= 1.0.8, < 2 development
  • sixarm_ruby_active_record_mock >= 1.4.4, < 2
.github/workflows/ruby.yml actions
  • actions/checkout v3 composite
  • ruby/setup-ruby v1 composite
Gemfile.lock rubygems
  • bundler 2.3.26
  • docile 1.4.0
  • minitest 5.18.0
  • rake 12.3.3
  • simplecov 0.22.0
  • simplecov-html 0.12.3
  • simplecov_json_formatter 0.1.4
  • sixarm_ruby_active_record_mock 1.4.6
  • sixarm_ruby_current_user 1.4.9
  • sixarm_ruby_minitest_extensions 1.1.1
Gemfile rubygems