Hello, I'm trying to create that callback method. Here's what I have so 
far.
post model:

class Post < ActiveRecord::Base
  after_create :check_posts_per_tag
  after_create :destroy_oldest_post_of_tag
  acts_as_taggable #<-- for acts_as_taggable_on_steroids
  validates_presence_of :body, :title, :tag_list
  has_many :comments

  #...

  def destroy_oldest_post_of_tag
    self.class.first.destroy
  end

  protected #<-- should this be protected?
  def check_posts_per_tag
    @inputtag = :tag_list #<-- will this grab the input from the form?
    @postspertag = post.tag_counts # maybe post.tag.count?
    if @inputtag.exists? then
      if @postspertag >= 20 then
        # delete the oldest post of that tag needs to happen here
        post.destroy_oldest_post_of_tag
      end
    end
  end
end

Does this look pretty close to what I described above? I'm trying to 
understand whats going on here. The comments in the code include some of 
my questions. I'm not sure if that's how I grab the input from the form, 
and I'm also not sure if that's how I would delete the oldest post of 
the given tag either...
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to