Skip to content
Browse files

Gar, I don't know what I'm doin...

  • Loading branch information...
1 parent ba238f8 commit 740df8e9bd00f1a9bc0e2499dd2141a84741d17d @nakajima committed
Showing with 15 additions and 8 deletions.
  1. +6 −6 app/models/bookmarklet.rb
  2. +8 −0 db/migrate/20100522140049_screw_the_column.rb
  3. +1 −2 db/schema.rb
View
12 app/models/bookmarklet.rb
@@ -1,17 +1,17 @@
class Bookmarklet < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :code
- validate :spam_check
-
- default_scope :conditions => { :spam => false }
+ validate :spam_check, :if => :spam?
attr_accessor :body # This is for spam detection
+
+ def spam?
+ @body.present? || SpamChecker.new(code).spam?
+ end
private
def spam_check
- if self.spam = @body || SpamChecker.new(code).spam?
- errors.add(:spam, "detection failed.")
- end
+ errors.add(:spam, "detection failed.")
end
end
View
8 db/migrate/20100522140049_screw_the_column.rb
@@ -0,0 +1,8 @@
+class ScrewTheColumn < ActiveRecord::Migration
+ def self.up
+ remove_column :bookmarklets, :spam
+ end
+
+ def self.down
+ end
+end
View
3 db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100522134227) do
+ActiveRecord::Schema.define(:version => 20100522140049) do
create_table "bookmarklets", :force => true do |t|
t.string "name"
@@ -19,7 +19,6 @@
t.datetime "updated_at"
t.text "description"
t.string "password"
- t.boolean "spam", :default => false
end
end

0 comments on commit 740df8e

Please sign in to comment.
Something went wrong with that request. Please try again.