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
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
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:
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)
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