GithubHelp home page GithubHelp logo

Comments (18)

farnoy avatar farnoy commented on May 5, 2024

Try params: { archive: :archive}
(notice that the first semicolon in this expression is dropped)

from public_activity.

pokonski avatar pokonski commented on May 5, 2024

That's incorrect Ruby syntax. Like @farnoy said.

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024

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.

pokonski avatar pokonski commented on May 5, 2024

How does your model look? Do you have custom accessors for archive?

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024

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.

farnoy avatar farnoy commented on May 5, 2024

Do you use any gems or libraries that could possibly give you the :archive method on your model?

from public_activity.

pokonski avatar pokonski commented on May 5, 2024

Also try alternative method:

tracked owner: Proc.new{ |controller, model| controller.current_user }, params: { archive: Proc.new{|_, model| model.archive} }

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024
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.

farnoy avatar farnoy commented on May 5, 2024

This one ?

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024

Yes

from public_activity.

pokonski avatar pokonski commented on May 5, 2024

Try the Proc method I posted above. If that doesn't work either then we will dig deeper.

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024

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.

cza0012 avatar cza0012 commented on May 5, 2024

In Proc.new{|_, model| model.archive}, what does the _ mean?

from public_activity.

pokonski avatar pokonski commented on May 5, 2024

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.

cza0012 avatar cza0012 commented on May 5, 2024

Thank you I am a newbie.

from public_activity.

cza0012 avatar cza0012 commented on May 5, 2024
  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.

pokonski avatar pokonski commented on May 5, 2024

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.

cza0012 avatar cza0012 commented on May 5, 2024

Thank you. I added this code, after the problem was solved at the first time.

from public_activity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.