Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access parameters from data #321

Open
brenoperucchi opened this issue Jul 25, 2018 · 8 comments
Open

Cannot access parameters from data #321

brenoperucchi opened this issue Jul 25, 2018 · 8 comments

Comments

@brenoperucchi
Copy link

brenoperucchi commented Jul 25, 2018

I cannot understand why it's happening now. I don't now if was happen because I recently upgrade to Rails 5. But suddenly I don't get access to object.parameters of activity

       tracked :owner      =>  proc {|controller, model| User.current.userable},
          :recipient  =>  proc {|controller, model| model.unit},
          :params => {:comment => "test" },
          :on => {
                   :update => proc {|model, controller| !model.comment.blank? }
                 }
>> activity.parameters[:comment]
!! #<TypeError: no implicit conversion of Symbol into Integer>
>> activity.parameters
=> "---\n:comment: test\n"
@brenoperucchi
Copy link
Author

brenoperucchi commented Jul 25, 2018

I had to insert this to back to work again.

#activity.rb
serialize :parameters, Hash

@pokonski
Copy link
Member

@brenoperucchi what version were you using? 1.6.0 fixes your issue I believe.

@brenoperucchi
Copy link
Author

public_activity (1.6.1)

@mssola
Copy link
Contributor

mssola commented Oct 18, 2018

Same in 1.6.2. I had to create a file and write the following to make it work:

module ::PublicActivity
  class Activity
    serialize :parameters, Hash
  end
end

Edit: when you run this on Travis (you start from an empty database), you'll get the following messages which weren't happening in Rails 4:

[WARN] table PublicActivity::ORM::ActiveRecord::Activity doesn't exist. Skipping PublicActivity::Activity#parameters's serialization

This might be related.

@pokonski
Copy link
Member

@mssola thanks for the details, I'll inspect as this definitely shouldn't happen.

@micahlisonbee
Copy link

I noticed that activities generated in response to seed data being created are stored in the db parameters column with traditional hash syntax, e.g.:

{:new_end_on=>"2019-07-17"}`

parameters for activities created during normal app usage and from console are stored like this:

---
:new_end_on: '2019-07-17'

I didn't even notice this until now because we had upgraded from Postgres 10 to Postgres 11 and it seems Postgres 11 barfs when trying to read/parse the traditional hash syntax (where Postgres 10/Active Record was able to parse both syntaxes w/out problems) with this error :

TypeError: no implicit conversion of Symbol into Integer

Also when deploying a review app on Heroku:

[WARN] table PublicActivity::ORM::ActiveRecord::Activity doesn't exist. Skipping PublicActivity::Activity#parameters's serialization

Following the above suggestions, I added serialize :parameters, Hash my PublicActivity module and the seed generated activity parameters data is now stored in the seemingly correct format:

module PublicActivity
  class Activity < inherit_orm('Activity')
    serialize :parameters, Hash
    ...
  end
end
---
:new_end_on: '2019-07-17'

@kernelsmith
Copy link

kernelsmith commented Jul 15, 2019

Any movement on this? I couldn't get the workaround (adding serialize :parameters, Hash) to work in 1.6.3 for some reason. I tried adding it directly to gems/2.4.0/gems/public_activity-1.6.3/lib/public_activity/activity.rb and I created a shim in config/initializers and added

module PublicActivity
  class Activity
    serialize :parameters, Hash
  end
end

But, I'm still getting undefined local variable or method parameters' for Class...`

@kernelsmith
Copy link

Also, I wanted to point out that it did work as of aff5b50 but that's right before you switched to inheriting from inherit_orm('Activity')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants