Let's see, there's a few approaches, the simplest would probably be to add a "approved" (or "isApproved" depending on your convention preference) field to the link model. Use the on_create callback to set self.approved=false. I haven't played with before_update enough to know if you could do that to flip an approved link that was editted back to unapproved. (Actually I know you could, but I don't know if it would also flip a non-dirty, but re-saved item also...)
If you need more states, then you could go with a link_status table and have links belong_to :link_status. (New, approved, updated, tagged_for_edit) if you want to deal with new and updated differently, and want to be able to mark something as "unapproved and needs to be fixed before I look at it again")
There is no "on_create" it seems. Only the following:
Also, this on create self.approved=false would go in the model right?
edit: i ended up doing this and I think it works. (have to fix my edit def first, it's giving me errors) But on the column I saw "false" on a new link I created.
My new link model
class Link < ActiveRecord::Base
validates_presence_of :title, :category, :description, :name, :email,
:on => :create, :message => "can't be blank"
validates_format_of :url, :with => /^(https?:\/\/)?([^\/]+)(\/.+)?$/i
self.approved = false
Last edited by DFischer (2006-12-29 19:48:56)
- Personal Web-Technology-Blog, Los Angeles.