acts_as_paranoidプラグインをインストールします。

acts_as_paranoidプラグインをインストールします。
[url=http://doruby.kbmj.com/]http://doruby.kbmj.com/[/url]
1 安装步骤

 $ ruby script/plugin source http://techno-weenie.net/svn/projects/plugins

$ ruby script/plugin install acts_as_paranoid


2

$ script/generate migration AddBooksDeletedAt #マイグレーションファイルの作成

$ less db/migrate/002_add_books_deleted_at.rb #マイグレーションファイルの編集

 class AddBooksDeletedAt < ActiveRecord::Migration

def self.up

add_column :book, :deleted_at, :datetime, :comment => "削除日時"

end

def self.down

remove_column :book, :deleted_at

end

end


3 $ rake db:migrate #マイグレーション

4 acts_at_paranoidの設定

class Book < ActiveRecord::Base

acts_as_paranoid

end

5

undefined method `
construct_count_options_from_args' for Book:Class


というエラーが表示されます。



これは最新のacts_as_paranoidプラグインがRails2.0に向けた対応をしたことによる影響らしいです。

そこで
RAILS_ROOT/vendor/plugins/acts_as_paranoid/lib/caboose/acts/paranoid.rb
の約95行目あたりの



 calculate_with_deleted(:count, *construct_count_options_from_args(*args)) 








 calculate_with_deleted(:count, *construct_count_options_from_legacy_args(*args)) 




に変更します。

これで削除をしてみるとうまく動作することが確認できます。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值