Comments (18)
Try params: { archive: :archive}
(notice that the first semicolon in this expression is dropped)
from public_activity.
That's incorrect Ruby syntax. Like @farnoy said.
from public_activity.
I am sorry that it is my typo. I actually use ruby params: { archive: :archive}
. I have try different name such as archive_question, but it does not work too.
from public_activity.
How does your model look? Do you have custom accessors for archive
?
from public_activity.
No, I add it into a table and put it to params. It show the error. If I remove it from params, the system work fine.
from public_activity.
Do you use any gems or libraries that could possibly give you the :archive
method on your model?
from public_activity.
Also try alternative method:
tracked owner: Proc.new{ |controller, model| controller.current_user }, params: { archive: Proc.new{|_, model| model.archive} }
from public_activity.
include PublicActivity::Model
attr_accessible :anonymous, :code, :content, :error, :title, :user_id, :notifications_attributes, :tag_list, :fast_answer, :archive
acts_as_taggable
validates :user_id, presence: true
#The number of questions per page
self.per_page = 10
# tracked
tracked owner: Proc.new{ |controller, model| controller.current_user }, params: { title: :title, content: :content, code: :code, error: :error, anonymous: :anonymous, fast_answer: :fast_answer, archive: :archive}
belongs_to :user, :inverse_of => :questions
has_many :usefuls, :as => :usefulable
has_many :comments, :inverse_of => :question
has_and_belongs_to_many :feedbacks
has_one :good_answer, :inverse_of => :question
has_many :notifications, :as => :sendable
accepts_nested_attributes_for :notifications, :reject_if => lambda { |a| a[:user_id].blank? }
after_save :automatic_feedback
before_save :tag_token
I used acts_as_taggable.
from public_activity.
This one ?
from public_activity.
Yes
from public_activity.
Try the Proc method I posted above. If that doesn't work either then we will dig deeper.
from public_activity.
It works fine. Thank you for your help.
tracked owner: Proc.new{ |controller, model| controller.current_user }, params: { archive: Proc.new{|_, model| model.archive} }```
from public_activity.
In Proc.new{|_, model| model.archive}, what does the _ mean?
from public_activity.
Normally you'd write
Proc.new{|controller, model| model.archive}
In Ruby _
can be used in place of a variable you don't need.
Also thank you for reporting the issue 👍, this clearly should not happen and we will investigate and fix if possible.
from public_activity.
Thank you I am a newbie.
from public_activity.
include PublicActivity::Model
attr_accessible :anonymous, :code, :content, :error, :title, :user_id, :notifications_attributes, :tag_list, :fast_answer, :deleted_question
acts_as_taggable
validates :user_id, presence: true
#The number of questions per page
self.per_page = 10
# tracked
# deleted_question should be archive_question
tracked owner: Proc.new{ |controller, model| controller.current_user }, params: { title: :title, content: :content, code: :code, error: :error, anonymous: :anonymous, fast_answer: :fast_answer, deleted_question: :deleted_question}
belongs_to :user, :inverse_of => :questions
has_many :usefuls, :as => :usefulable
has_many :comments, :inverse_of => :question
has_and_belongs_to_many :feedbacks
has_one :good_answer, :inverse_of => :question
has_many :notifications, :as => :sendable
accepts_nested_attributes_for :notifications, :reject_if => lambda { |a| a[:user_id].blank? }
after_save :automatic_feedback
# before_save :tag_tokens
def deleted_question
self.lock!
self.deleted_question = true
self.save
end
I found that if attribute and method have a same name, it will create too deep stack error.
from public_activity.
No, you are creating the stack too deep error:
def deleted_question
self.lock!
self.deleted_question = true
self.save
end
Basically every time you are accessing deleted_question it saves itself, then tries to create an activity about it, then accesses the deleted_question which saves itself again. It's stuck in an infinite loop calling itself all the time. So you do create custom accessors, I asked about it before and you said you don't.
Also saving a model from inside a getter is a bad, bad practice, don't do it. I don't think you realize what it does. Why would you ever want to change the value while trying to access it?
from public_activity.
Thank you. I added this code, after the problem was solved at the first time.
from public_activity.
Related Issues (20)
- I got this Error only on Heorku even Dev and Prod env is perfect ton local HOT 9
- Gem requires db connection during assets precompile HOT 9
- After setting up public_activity missing render HOT 1
- How to handle activity where parameters is empty? HOT 1
- why public_activity dependency is not resolved by actionpack gem with version 6.0.4 HOT 2
- Random odd failure when PublicActivity.with_tracking used in Rails app with RSpec HOT 1
- Commits for new versions not in Github HOT 2
- Trying to return activity text such as "updated ..." in API HOT 1
- Release notes for 2.0.0 HOT 1
- Issue when tracking is triggered from within a thread HOT 3
- Custom After_Commit callback when activities are created HOT 2
- Callbacks not triggered when used in combination with activerecord-import HOT 2
- DRY Rendering activities using ViewComponent HOT 3
- Psych::DisallowedClass: Tried to load unspecified class: Symbol HOT 5
- Heroku demo site is down HOT 1
- TypeError: no implicit conversion of Symbol into Integer HOT 2
- Was :fallback accidentally left out? HOT 1
- missing keyword: :coder If no default coder is configured, a coder must be provided to `serialize`. rails 7 HOT 10
- ActiveRecord::Base.serialize signature changed when ActiveRecord >= 7.1 HOT 1
- v3 has breaking change (parameters defaults to nil) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from public_activity.