{"id":31723272,"url":"https://github.com/icalialabs/acts_as_user","last_synced_at":"2025-10-09T04:47:51.003Z","repository":{"id":12458009,"uuid":"15120565","full_name":"IcaliaLabs/acts_as_user","owner":"IcaliaLabs","description":"A gem which handles multiple types of users on a rails app","archived":false,"fork":false,"pushed_at":"2020-06-13T01:59:36.000Z","size":39,"stargazers_count":24,"open_issues_count":4,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-06T23:14:55.835Z","etag":null,"topics":["devise","gem","polymorphic-relationships","rails","ruby","user-handling"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IcaliaLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-11T22:14:51.000Z","updated_at":"2020-01-04T23:04:15.000Z","dependencies_parsed_at":"2022-09-13T20:00:14.049Z","dependency_job_id":null,"html_url":"https://github.com/IcaliaLabs/acts_as_user","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IcaliaLabs/acts_as_user","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IcaliaLabs%2Facts_as_user","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IcaliaLabs%2Facts_as_user/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IcaliaLabs%2Facts_as_user/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IcaliaLabs%2Facts_as_user/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IcaliaLabs","download_url":"https://codeload.github.com/IcaliaLabs/acts_as_user/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IcaliaLabs%2Facts_as_user/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000700,"owners_count":26082921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["devise","gem","polymorphic-relationships","rails","ruby","user-handling"],"created_at":"2025-10-09T04:47:47.209Z","updated_at":"2025-10-09T04:47:50.998Z","avatar_url":"https://github.com/IcaliaLabs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Acts as user\n[![Build Status](https://travis-ci.org/IcaliaLabs/acts_as_user.png?branch=master)](https://travis-ci.org/IcaliaLabs/acts_as_user)\n[![Code Climate](https://codeclimate.com/github/IcaliaLabs/acts_as_user.png)](https://codeclimate.com/github/IcaliaLabs/acts_as_user)\n[![Dependency Status](https://gemnasium.com/IcaliaLabs/acts_as_user.png)](https://gemnasium.com/IcaliaLabs/acts_as_user)\n[![Gem Version](https://badge.fury.io/rb/acts_as_user.png)](http://badge.fury.io/rb/acts_as_user)\n\nActs as user handles multiple user roles on a rails app. It uses polymorphic associations to relate other models and behave like a user.\n\n\n## Getting started\n\nActsAsUser 1.2.1 works with rails 3 onwards. You can add it to your Gemfile with:\n\n```ruby\ngem 'acts_as_user'\n```\n\nThen run the bundle command to install it.\n\nAfter you install ActsAsUser you need to run the generator:\n\n```console\nrails g acts_as_user:install\n```\n\nThe generator will install in initializer which describes all the ActsAsUser configuration options, so we recommend you take a look at it. When you are done you are ready to start your user model:\n\n```console\nrails g acts_as_user User \u003cattributes\u003e\n```\n\nNext you'll probably want to run the migrations \"rake db:migrate\", as the generator will create a migration file (open it modify if you need to).\n\n## Configuration\n\nFor the models you want to inherit to you just have to add this line of code into them:\n\n```ruby\nclass Member\n\tacts_as_user\nend\n```\n\nA little note on the User model...just in case!\n\n```ruby\nclass User\n\tis_user\nend\n```\n\n### Ignore attributes to delegate from the user\n\nIf you want to ignore some attributes from your user model to the childs, you can do it on the ```acts_as_user.rb``` initializer like so:\n\n```ruby\nActsAsUser.setup do |config|\n\tconfig.ignored_attributes = [\"name\", \"bio\"]\nend\n```\n\nBy default it ignores the following attributes:\n\n```ruby\n[\"created_at\", \"updated_at\", \"id\", \"userable_type\", \"userable_id\"]\n```\n\n\n## Devise support\n\nYes we do!\n\nActs as a user plays well with Devise as it ignores and adds the corresponding attributes to delegate to.\n\nWhen using devise, ActsAsUser will also ignore the ```encrypted_password``` attribute from the user. No further configuration needs to be done.\n\n## Getting to know the user\n\nActsAsUser gem now adds some handy instance user methods that returns true or false wheter the current user is a specific type or not, for example:\n\nA simple configuration may look something similar to:\n\n```ruby\nclass User \u003c ActiveRecord::Base\n is_user\nend\n\nclass Customer \u003c ActiveRecord::Base\n acts_as_user\nend\n\nclass Admin \u003c ActiveRecord::Base\n acts_as_user\nend\n```\n\nJust a little configuration is needed, you can do it on the ```acts_as_user.rb``` initializer like so:\n\n```ruby\nActsAsUser.setup do |config|\n\tconfig.models_acting_as_users = [:admin, :customer]\nend\n```\n\nNow we will instantiate a Customer object:\n\n```console\ncustomer = Customer.find(1)\ncurrent_user = customer.user\n```\n\nYou now should be able to detect in this case if the current_user is wheter an admin or a customer by simply calling:\n\n```console\ncurrent_user.customer?\n =\u003e true\ncurrent_user.admin?\n =\u003e false\n```\n\nEnjoy!\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\n### Psst! Here is a live example in rails\n\n[Rails acts as user example](https://github.com/IcaliaLabs/acts_as_user_example)\n\n### Devs\n\n* Abraham Kuri (https://github.com/kurenn)\n* Patricio Beltrán (https://github.com/patobeltran)\n\n### Future\n\n* Support for Mongoid\n* Add wiki\n\n\n## Credits\nIcalia Labs - weare@icalialabs.com\n\n[Follow us](http://twitter.com/icalialabs \"Follow us\")\n\n\n[Like us on Facebook](https://www.facebook.com/icalialab \"Like us on Facebook\")\n\n\n### License\n\nMIT License. Copyright 2012-2013 IcaliaLabs. http://icalialabs.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficalialabs%2Facts_as_user","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficalialabs%2Facts_as_user","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficalialabs%2Facts_as_user/lists"}