【ruby on rails】acts_as_paranoid

論理削除を自動的にやってくれるプラグイン(acts_as_paranoid)があると知って、さっそくインストールしよう思ったんだけど、プラグインが見つからないと怒られる
ウワァァァァァァヽ(`Д´)ノァァァァァァン!

 $ ./script/plugin install acts_as_paranoid
 Plugin not found: ["acts_as_paranoid"]

参考:
http://d.hatena.ne.jp/yukiwata/20070604/1180966217
http://i-am.web777.net/2007/01/activerecord.html

タグ:[ruby on rails

このログへのコメント(2件)

rootでやれば出来た(汗

# gem install -r acts_as_paranoid

てなわけで早速プラグインをインスコ

 # ./script/plugin install acts_as_paranoid


親テーブルと子テーブル、それぞれにdeleted_atカラムを追加。
-- migrate
class AddLogColumn < ActiveRecord::Migration
def self.up
add_column :logs, :deleted_at, :datetime
end

def self.down
remove_column :logs, :deleted_at, :datetime
end
end

class AddCommentColumn < ActiveRecord::Migration
def self.up
add_column :comments, :deleted_at, :datetime
end

def self.down
remove_column :comments, :deleted_at, :datetime
end
end


モデルにacts_as_paranoidを追加

class logs
acts_as_paranoid
end

class comments
acts_as_paranoid
belongs_to :log
end


で完了ということで、起動してみると。ActiveRecord.countにて、なにやらconstruct_count_options_from_argsメソッドが無いと怒られる orz

undefined method `construct_count_options_from_args'

ぐぐって見てると、
vendor/plugins/acts_as_paranoid/lib/caboose/acts/paranoid.rbの88行目にてconstruct_count_options_from_argsをコールしているとこまでは分かった。
で、どうしろとって感じなのですが、construct_count_options_from_legacy_argsがどうのこうのとコメントが書かれてるので、駄目元で変更

def count_with_deleted(*args)
calculate_with_deleted(:count, *construct_count_options_from_args(*args))
end


def count_with_deleted(*args)
calculate_with_deleted(:count, *construct_count_options_from_legacy_args(*args))
end


よく分からんが、動いたw
RubyのバージョンかActiveRecordのバージョンか知らないけど、何か古いのですかね。

コメント投稿フォーム

コメント

※半角英数字だけのコメントは投稿できません。

トラックバック

関連ログ