{"id":22808337,"url":"https://github.com/sixarm/sixarm_ruby_current_user","last_synced_at":"2026-04-13T09:32:29.601Z","repository":{"id":1122996,"uuid":"995873","full_name":"SixArm/sixarm_ruby_current_user","owner":"SixArm","description":"SixArm.com » Ruby » Get the current user of a Ruby on Rails app","archived":false,"fork":false,"pushed_at":"2025-04-14T09:18:27.000Z","size":334,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-26T14:19:54.629Z","etag":null,"topics":["current-user","gem","rails","ruby"],"latest_commit_sha":null,"homepage":"http://sixarm.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SixArm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2010-10-18T00:20:23.000Z","updated_at":"2025-04-14T09:18:30.000Z","dependencies_parsed_at":"2025-04-14T10:25:20.095Z","dependency_job_id":"5b182265-8492-4f44-98c1-e52fea73a380","html_url":"https://github.com/SixArm/sixarm_ruby_current_user","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SixArm/sixarm_ruby_current_user","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_current_user","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_current_user/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_current_user/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_current_user/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SixArm","download_url":"https://codeload.github.com/SixArm/sixarm_ruby_current_user/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_current_user/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31746294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["current-user","gem","rails","ruby"],"created_at":"2024-12-12T11:09:17.443Z","updated_at":"2026-04-13T09:32:29.585Z","avatar_url":"https://github.com/SixArm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SixArm.com → Ruby → \u003cbr\u003e CurrentUser module with current_user methods\n\n* Doc: \u003chttp://sixarm.com/sixarm_ruby_current_user/doc\u003e\n* Gem: \u003chttp://rubygems.org/gems/sixarm_ruby_current_user\u003e\n* Repo: \u003chttp://github.com/sixarm/sixarm_ruby_current_user\u003e\n\u003c!--header-shut--\u003e\n\n\n## Introduction\n\nGet and set the current user in the Rails session array.\n\nWhen you set the current user, this does:\n - @current_user = user\n - @current_user_id = user.id\n - session[:current_user_id] = user.id\n\nFor docs go to \u003chttp://sixarm.com/sixarm_ruby_current_user/doc\u003e\n\nWant to help? We're happy to get pull requests.\n\n\n\u003c!--install-open--\u003e\n\n## Install\n\n### Gem\n\nTo install this gem in your shell or terminal:\n\n    gem install sixarm_ruby_current_user\n\n### Gemfile\n\nTo add this gem to your Gemfile:\n\n    gem 'sixarm_ruby_current_user'\n\n### Require\n\nTo require the gem in your code:\n\n    require 'sixarm_ruby_current_user'\n\n\u003c!--install-shut--\u003e\n\n\n## Example code\n\n    joe = User.find(123)\n    self.current_user = joe\n    =\u003e\n    @current_user == joe\n    @current_user_id == 123\n    session[:current_user_id] == 123\n\n\n## Example controller\n\n    class MyController \u003c ApplicationController\n\n      def sign_in(user)\n        self.current_user = user\n      end\n\n      def sign_out\n        self.current_user = nil\n      end\n\n      def is_anyone_using_this?\n        current_user?\n      end\n\n    end\n\n\n## Example of reloading\n\nFor fast speed, we memoize current_user and current_user_id:\nwe use fast instance variables @current_user and @current_user_id\nrather than reading the slower session[:current_user_id] each time.\n\nTo reload @current_user and @current_user_id from session[:current_user_id],\nwe use the :reload parameter like this:\n\n    current_user(:reload =\u003e true)\n\n\n## Why use the self prefix?\n\nWhen we set variables, we must use the \"self\" prefix because Ruby uses this to do method dispatch.\n\nRight:\n\n    self.current_user = joe\n\nWrong:\n\n    current_user = joe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_current_user","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixarm%2Fsixarm_ruby_current_user","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_current_user/lists"}