Skip to content

Commit

Permalink
add 'removed' flag to books (used instead of actual removal)
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr committed Nov 30, 2010
1 parent 4e4d4a7 commit 95a7cba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Book < ActiveRecord::Base

validate :isbn_is_valid

default_scope order('created_at DESC').where(:removed => false)

def isbn_is_valid
true
end
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20101130031704_add_removed_to_book.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddRemovedToBook < ActiveRecord::Migration
def self.up
add_column :books, :removed, :boolean, :default => false
end

def self.down
remove_column :books, :removed
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20101128042909) do
ActiveRecord::Schema.define(:version => 20101130031704) do

create_table "books", :force => true do |t|
t.string "isbn", :limit => 13
Expand All @@ -22,6 +22,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
t.boolean "removed", :default => false
end

create_table "users", :force => true do |t|
Expand Down

0 comments on commit 95a7cba

Please sign in to comment.