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
How to use model callback methods? #918
Comments
Hi @ccoeder, The issue you're facing is that the model you are using is adding tags to the class ActsAsTaggableOn::Tag
after_save do
puts "It should come here; it's working now"
end
end
# generated with `rails g model User reason:string`
class User < ActiveRecord::Base
acts_as_taggable
def update_reason(reason)
self.reason = reason
self.tag_list.add(self.reason.scan(/#(\w+)/).flatten.uniq) unless self.reason.nil?
reason
end
end # disable logging so that we can see the message
ActiveRecord::Base.logger = nil
user = User.new
user.update_reason "#2"
user.save #=> "It should come here; it's working now" In the future, questions like this are probably better addressed on sites like StackOverflow. This issue can be closed. |
Thank you! |
This is not working for me. Where should this file be located? |
Hi,
I want to broadcast most used tags so I think I need something like
after_save
orafter_create_commit
how can I achieve this?act-as-taggable model
self.tag_list.add(self.reason.scan(/#(\w+)/).flatten.uniq) unless self.reason.nil?
and my tag model inherits from act-as-taggable
Thanks.
The text was updated successfully, but these errors were encountered: