Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:10:05+00:00 2026-06-02T14:10:05+00:00

I’m not sure this is possible, but given the way you can inject a

  • 0

I’m not sure this is possible, but given the way you can inject a method into modules, is there a way to inject “acts_as_readable :on => :updated_at” into PublicActivity::Activity?

The issue is this: I want unread to also track the new activities the user has not yet seen, so I first tried it this way.

class Activity < PublicActivity::Activity
  acts_as_readable :on => :updated_at
end

class User < ActiveRecord::Base
  acts_as_reader
end

However I noticed in the record (DB table read_marks) when I do

Activity.mark_as_read! :all, :for => current_user

that the readable_type key is set to ‘PublicActivity::Activity’ instead of ‘Activity’

This is because the Unread gem uses

user.read_marks.build(:readable_id => obj.id, :readable_type => self.base_class.name)

that base_class gives the class closest to ActiveRecord::Base
What would be the best option?

1) inject somehow the ‘acts_as_readable :on => :updated_at’ directly into PublicActivity::Activity

2) fork PublicActivity and check if Unread gem is installed, if so add the line ‘acts_as…’

3) fork the Unread gem and … not sure what I would do here, the first ugly thing that comes to mind would be to check if a class begins with PublicActivity!

And just to define the issue: Since the record’s (DB table read_marks) readable type is PublicActivity::Activity and not Activity, my

Activity.unread_by(current_user).count

never returns the correct count. Using

PublicActivity::Activity.unread...

would fail since the ‘acts_as_readable :on => :updated_at’ is in Activity and not PublicActivity::Activity.

UPDATE

I’ve tried to ‘monkey-patch’ the Public_Activity plugin but now I’m even more confused as to why it fails, it must be something dumb I’m doing. I added the following file. However the readable_type is still PublicActivity::Activity and my count remains the same after I do

PublicActivity::Activity.mark_as_read! :all, :for => current_user


# config/initializers/activity_unread.rb
PublicActivity::Activity.module_eval do

  acts_as_readable :on => :updated_at

end

UPDATE

AH! It was the readable_type field having a limit of only 20 that was truncating my class name. Now it works after I increased the size.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:10:08+00:00Added an answer on June 2, 2026 at 2:10 pm

    reko

    Not sure if you found the solution, but to get rid of the error (I am using Ruby 1.9.3 & Rails 3.2) change

    PublicActivity::Activity.template = YAML.load_file(“#{RAILS_ROOT}/config/pba.yml”)

    to

    PublicActivity::Activity.template = YAML.load_file(“#{Rails.root}/config/pba.yml”)

    I created a file called pba_setup and inserted the above line in the initializer folder. Now that cleared up the error when loading, but I still get a missing template error? Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.