# Improving discovery of the badge title feature

**URL:** <https://meta.discourse.org/t/improving-discovery-of-the-badge-title-feature/27372>\
**Category:** Feature\
**Created:** [2015 年4 月 9 日 08:57 UTC](https://meta.discourse.org/t/improving-discovery-of-the-badge-title-feature/27372 "2015-04-09T08:57:09Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

作者： ![designbygio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/designbygio/32/122415_2.png) [@designbygio](https://meta.discourse.org/u/designbygio)\
发布日期： [2017 年4 月 23 日 12:58 UTC](https://meta.discourse.org/t/improving-discovery-of-the-badge-title-feature/27372/10 "2017-04-23T12:58:36Z")

</div>

Start to work on this feature.  
But I would need some Rails guideline here.  
I figured out that the notifications are created from this file

> <https://github.com/discourse/discourse/blob/7b6242bfbb52486318d0136d230bc2c5790a52dd/app/assets/javascripts/discourse/widgets/notification-item.js.es6>

which display badge name and link. The attributes that this file got are

- badge id
- badge name
- badge slug
- username

In order to add the “this badge can be used as title” just to the badge that can be used to has title, i wanted to send another attr: `allow-title`  
I believe the file that handle the attrs to send is

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/app/jobs/scheduled/badge_grant.rb>

I added `badge: @badge` to the `grant` method to see what’s inside of badge but it doesn’t display nothing, not even an error.  
I’m also having hard time to debug this part, i’m not rails devs so i really don’t know how to do it properly but i try with `debugger`, `pry` and `byebug`.  
The console never stop.

I’m i looking at the right file? How can i properly debug this part?

this is what i change inside the `grant` method:

```plaintext
user_badge = UserBadge.create!(badge: @badge,
                                       user: @user,
                                       granted_by: @granted_by,
                                       granted_at: @opts[:created_at] || Time.now,
                                       post_id: @post_id,
                                       seq: seq)

```

```plaintext
unless @badge.badge_type_id == BadgeType::Bronze && user_badge.granted_at < 2.days.ago
            I18n.with_locale(@user.effective_locale) do
              notification = @user.notifications.create(
                notification_type: Notification.types[:granted_badge],
                data: { badge: @badge,
                        badge_id: @badge.id,
                        badge_name: @badge.display_name,
                        badge_slug: @badge.slug,
                        username: @user.username}.to_json,
              )
              user_badge.update_attributes notification_id: notification.id
            end
          end

```

---

_[View the full topic](https://meta.discourse.org/t/improving-discovery-of-the-badge-title-feature/27372)._
