Rethinking Content Whiteboards

At the moment we’re holding whiteboards as a serialised field in
contents table. Which was fine when we were also caching the HTML
representations there too – whiteboards generally got (re)generated
during text formatting and got magically saved along with the html
renderings.

But now, the rendered html is managed by the controller and held in
a different sort of cache, so the article doesn’t get saved, so the
whiteboard data gets thrown away. Which is not good.

So, my thinking is add something like:

class Whiteboard
serialize :data

 def method_missing(:method, *args)
   method.to_s =~ /^(.*)(=?)$/
   key = $1
   is_assignment = !$2.blank?

   unless data.has_key? key
     return super(:method, *args)
   end

   if is_assignment
     data[key] = *args
   else
     data[key]
   end
 end

end

And having a table definition like

create_table :whiteboards do |t|
t.column :name, :string
t.column :data, :text
end

The tricky part might be in getting a working acts_as_hash
implementation, but that’s a SMOP.

Thoughts?

Sounds good.

After watching my logs yesterday, I’m seriously considering ditching a
lot of the sweeper implementation and switching to something like
this:

if Article, Page, or Settings changed -> sweep everything
elsif Comment or Trackback -> sweep page, add +60 minute trigger to
sweep everything if one doesn’t already exist.

We should probably also add a ‘if comment is published’ in there
somewhere, because even spam comments are nuking my cache.

Scott

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs