Кто-нибудь знает, почему этот метод обратного вызова будет работать в Rails 2.3.x / Ruby 1.8.7, но не в Rails 3.0.x / Ruby 1.9.2?
Работает в Rails 2.3.x / Ruby 1.8.7:
class Post < ActiveRecord::Base
after_create :destroy_old_posts
acts_as_taggable
# ...
protected
def destroy_old_posts
self.tag_list.each do |tag|
posts = Post.find_tagged_with(tag, :order => 'updated_at DESC')
posts[19..-1].each {|p| p.destroy } if posts.size >= 20
end
end
end
Но с 3.0.x / Ruby 1.9.2 при создании сообщения я получаю следующую ошибку:
undefined method `find_tagged_with' for #<Class:0x00000002943048>
app/models/post.rb:30:in `block in destroy_old_posts'
app/models/post.rb:29:in `each'
app/models/post.rb:29:in `destroy_old_posts'
app/controllers/posts_controller.rb:29:in `block in create'
app/controllers/posts_controller.rb:28:in `create'
Я использую acts-as-taggable-on
2.0.6. Спасибо, что прочитали мой вопрос.