Hi,
I tried running commands in rails c
such as User.find(1).update(ip_address: nil, topics_viewed: nil)
to update the things in this list below - however, I kept getting errors:
How would I change these values?
Thanks.
Hi,
I tried running commands in rails c
such as User.find(1).update(ip_address: nil, topics_viewed: nil)
to update the things in this list below - however, I kept getting errors:
How would I change these values?
Thanks.
What errors are you getting?
Some of those things live in other tables/models. Email addresses, for example, are in their own table, so you need to update those there.
What problem are you solving?
Just trying to reset statistics, want to get rid of topics_viewed, posts_read, read_time and last_emailed. Not interested in user details as they can be changed using the interface, only the values that affect the user’s profile but cannot be edited.
They can’t be edited because they aren’t part of the user model.
There’s a model that keeps up with what topics a user has viewed (TopicViewItem
), so you’d need to clear those (maybe TopicViewItem.destroy_all
– no – that doesn’t work.) and then run whatever updates that. And if they were emailed, then the last time they were emailed is going to be the last time they were emailed.
There’s a PostTiming
model that keeps up with what posts are read, and
read time. Ah, you can search the source for PostTiming
and find something like
PostTiming.destroy_for(current_user.id, [topic_id])
So that’s a start. Maybe this:
PostTiming.destroy_for(1, PostTiming.where(user_id: 1).pluck(:topic_id).uniq))
There are some ensureconsistency
tasks that might be how to update those, but I’m not quite sure.
In that case, is it possible to merge an admin account via the console? I’m aware it’s not with the admin interface.
Just remove their admin privs and do it?
But it looks like you can do it with a rake task: Merging user accounts
Thanks for that - not sure if it’s possible to take away the original administrator’s admin privileges though.
If it’s a developer (that’s set in the app.yml) then I think you’re right.
Also, I just noticed this rake task!
rake destroy:stats
Looks like that might do what you want.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.