Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2008 20:26
Show Gist options
  • Save anonymous/9016 to your computer and use it in GitHub Desktop.
Save anonymous/9016 to your computer and use it in GitHub Desktop.
class Update < ActiveRecord::Base
belongs_to :job_id, :foreign_key => 'job_id', :class_name => 'Job'
file_column :attachment
def authorized_for_destroy?
require 'pp'
pp self
if created.nil? then
false
else
system "echo 1 >/tmp/here"
newer_updates = Update.find_by_sql(
"SELECT * FROM updates
WHERE
(created > '#{self.created.strftime("%Y-%m-%d %H:%M:%S")}')"
)
if (newer_updates.length==0) then
true
else
false
end
end
end
def authorized_for_update?
false
end
def before_create
self.author_email = "#{current_user}@engr.uconn.edu"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment