# Plugin working locally But not in live

**URL:** https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316
**Category:** Development
**Created:** [2017年四月2日 11:35 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316 "2017-04-02T11:35:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2017年四月2日 11:35 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/1 "2017-04-02T11:35:57Z")

</div>

Continuing the discussion from [Timeline - Social Network like News Feed UI in Topic List](https://meta.discourse.org/t/timeline-social-network-like-news-feed-ui-in-topic-list/60312):

My above plugin working perfectly on localhost as it in screenshots. But I can’t see any updates in live website.

Looks like below code is not working. I am not getting `unread_post` field in `latest.json` response.

> <https://github.com/VinkasHQ/discourse-timeline/blob/master/plugin.rb#L11-L23>

I can see the plugin name in both plugins list and upgrade pages.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2017年四月3日 14:22 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/2 "2017-04-03T14:22:54Z")

</div>

I just fixed it myself 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年四月3日 14:26 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/3 "2017-04-03T14:26:03Z")

</div>

What was wrong? 🐛

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2017年四月3日 14:29 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/4 "2017-04-03T14:29:30Z")

</div>

@sam `TopicListItemSerializer` is inherited class of `ListableTopicSerializer`. If I monkey patch `ListableTopicSerializer` it is not working on live version. Instead if I monkey patch `TopicListItemSerializer` it is working on both local and live. Weird 😳

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年四月3日 14:32 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/5 "2017-04-03T14:32:45Z")

</div>

wow, strange, maybe the serializer was being patched too late in the process after it already cached certain data.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2017年四月3日 14:34 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/6 "2017-04-03T14:34:20Z")

</div>

Yes. I think so. May be `eager_load` or `cache_classes` doing that part.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2018年十月17日 14:35 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/9 "2018-10-17T14:35:44Z")

</div>

I just spent a long time debugging an issue caused by this. I was doing

```plaintext
add_to_serializer(:admin_user, :somefield)...

```

which worked fine in development, but not in production. Changing it to `:admin_detailed_user` fixed the problem (admin\_detailed\_user inherits from admin\_user).

It would be good if we can either fix this, or at least add a warning. Differences between dev/prod are painful!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年十月17日 23:44 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/10 "2018-10-17T23:44:36Z")

</div>

> [@david](#):
>
> It would be good if we can either fix this, or at least add a warning. Differences between dev/prod are painful!

100% in agreement here ❤ if you can figure out any way to make this explode consistently on both prod and dev it would be awesome… My guess is that this is somehow related to the reloaders.

One sad thing about relying on “reload” magic is that there is a lot of magic. Its one big reason we moved away from using sprockets (and never jumped on the spring train) … it just got too hard to fit the mold of reloading without side effects.

(this could be not reload related, but hey, its a nice story 🤪 )

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2020年四月16日 20:39 UTC](https://meta.discourse.org/t/plugin-working-locally-but-not-in-live/60316/11 "2020-04-16T20:39:38Z")

</div>

我刚刚又遇到了这个问题，并发现了这个主题。看起来 @sam 为插件 API 添加了一个修复，解决了这个问题 😃

> <https://github.com/discourse/discourse/commit/bd5fa1737d42a958bb5cda35ae5bab2464d4e084>
>
> This is a very long standing bug we had, if a plugin attempted to amend a
> serial…izer core was not "correcting" the situation for all descendant classes
> this often only showed up in production cause production eager loads serializers
> prior to plugins amending them.
> 
> This is a critical fix for various plugins

因此，就此结束：如果你遇到这个问题，请确保使用 `add_to_serializer` API，而不是自己修改类。
