[openstreetmap/openstreetmap-website] Manually status enabled for user `statusAASM::NoDirectAssignmentError` (Issue #3460)
Ruben L. Mendoza
notifications at github.com
Wed Feb 16 00:05:43 UTC 2022
### URL
_No response_
### How to reproduce the issue?
Hey openstreetmap-website's developers, I am trying to change the status of a user using the `Managing Users` section
https://github.com/openstreetmap/openstreetmap-website/blob/master/CONFIGURE.md#managing-users
It is useful when we don't want to send confirmation emails to users and manually enable users to edit on the map.
The issue is that we can not change the status of the user manually , it throws the error 👉 `AASM::NoDirectAssignmentError (direct assignment of AASM column has been disabled (see AASM configuration for this class))`
```sh
irb(main):011:0> user = User.find_by(:display_name => "devseed")
irb(main):012:0>
irb(main):013:0> user.status = "active"
Traceback (most recent call last):
1: from (irb):12
AASM::NoDirectAssignmentError (direct assignment of AASM column has been disabled (see AASM configuration for this class))
irb(main):014:0>
irb(main):015:0> user.save!
```
Currently the only way to make user active is with email confirmation.
So, I solution that I found is editing the line: https://github.com/openstreetmap/openstreetmap-website/blob/319e54e08a9803c2218ec126bce4ed6eb9965127/app/models/user.rb#L162 and changing the `no_direct_assignment` value from `true` to `false` 👇
`aasm :column => :status, :no_direct_assignment => true do` -----> `aasm :column => :status, :no_direct_assignment => false do`
updating that line, the user’s status changed successfully.
```sh
irb(main):002:0> user = User.find_by(:display_name => "devseed")
irb(main):003:0> user.status = "active"
irb(main):004:0> user.save!
=> true
irb(main):005:0> user
=> #<User email: "rub2106 at gmail.com", id: 2, pass_crypt: "..", creation_time: "2022-02-15 23:01:26.478201000 +0000", display_name: "devseed", data_public: true, description: "", home_lat: nil, home_lon: nil, home_zoom: 3, pass_salt: nil, email_valid: false, new_email: nil, creation_ip: "10.112.0.1", languages: "en-US,en,es", status: "active", terms_agreed: "2022-02-15 23:01:26.171538000 +0000", consider_pd: false, auth_uid: nil, preferred_editor: nil, terms_seen: true, description_format: "markdown", changesets_count: 0, traces_count: 0, diary_entries_count: 0, image_use_gravatar: false, auth_provider: nil, home_tile: nil, tou_agreed: "2022-02-15 23:01:26.171573000 +0000">
```
Can this line be updated in core code?
cc. @batpad
### Screenshot(s) or anything else?
_No response_
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/3460
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/issues/3460 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20220215/fa8539e9/attachment-0001.htm>
More information about the rails-dev
mailing list