# Add likes programmatically?

**URL:** <https://meta.discourse.org/t/add-likes-programmatically/242993>\
**Category:** Product Support\
**Created:** [October 26, 2022, 6:24pm UTC](https://meta.discourse.org/t/add-likes-programmatically/242993 "2022-10-26T18:24:50Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)\
**Post date:** [November 14, 2022, 10:27pm UTC](https://meta.discourse.org/t/add-likes-programmatically/242993/5 "2022-11-14T22:27:01Z")

</div>

If anyone wants to do this, here’s what worked for me. Open the rails console and run:

```plaintext
p = Post.find(31871)
u = User.find_by(username:"xxx")
PostActionCreator.create(u, p, :like, created_at: Time.now)

```

Obviously you will have to swap out the post id and the username

---

_[View the full topic](https://meta.discourse.org/t/add-likes-programmatically/242993)._
