# Ember error on Unpinning, Archiving topic

**URL:** <https://meta.discourse.org/t/ember-error-on-unpinning-archiving-topic/56253>\
**Category:** Product Support\
**Created:** [24 يناير 2017، 6:13ص UTC](https://meta.discourse.org/t/ember-error-on-unpinning-archiving-topic/56253 "2017-01-24T06:13:52Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jgujgu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jgujgu/32/64012_2.png) [@jgujgu](https://meta.discourse.org/u/jgujgu)\
**Post date:** [25 يناير 2017، 12:23ص UTC](https://meta.discourse.org/t/ember-error-on-unpinning-archiving-topic/56253/5 "2017-01-25T00:23:52Z")

</div>

Well, thank you for scrutinizing this. @eviltrout my first instinct should’ve been to check the server. :facepalm:

So, while I know how to remedy the problem, I still don’t know why it happens.

My plugin uses a callback

```ruby
DiscourseEvent.on(:post_created) do |post, opts, user|
    #the work
end

```

Before now, I did not have a guard clause checking the `post_type`. Now, I make sure it’s `post_type == 1` (the pinned “post” was type 3). For some reason, not having the guard clause would raise this error, on the newly created post:

```ruby
ActiveRecord::RecordInvalid - Validation failed: Body is too short (minimum is 20 characters), Body seems unclear, is it a complete sentence?:
  activerecord (4.2.7.1) lib/active_record/validations.rb:79:in `raise_record_invalid'
  activerecord (4.2.7.1) lib/active_record/validations.rb:43:in `save!'
  activerecord (4.2.7.1) lib/active_record/attribute_methods/dirty.rb:29:in `save!'
  activerecord (4.2.7.1) lib/active_record/transactions.rb:291:in `block in save!'
  activerecord (4.2.7.1) lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
  activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
  activerecord (4.2.7.1) lib/active_record/transactions.rb:220:in `transaction'
  activerecord (4.2.7.1) lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
  activerecord (4.2.7.1) lib/active_record/transactions.rb:291:in `save!'

```

**Edit:** The weird part to me is that this validation (which probably normally doesn’t run for post\_type 3) did run when the I delineated the callback.

---

_[View the full topic](https://meta.discourse.org/t/ember-error-on-unpinning-archiving-topic/56253)._
