나는이에 대한 인기 보석 또는 플러그인가 있다는 것을 모른다; 메모리에서
: 과거에 내가와 ApplicationController에 before_filter
으로 감사의 이런 종류를 구현했습니다
class ApplicationController < ActionController::Base
before_filter :audit_events
# ...
protected
def audit_events
local_params = params.clone
controller = local_params.delete(:controller)
action = local_params.delete(:action)
Audit.create(
:user => current_user,
:controller => controller,
:action => action,
:params => local_params
)
end
end
이는 물론, 현재 사용자를 얻을 수 restful_authentication 같은 것을 사용하고 있다고 가정합니다.
편집 : 액티브의 assoiations == 가장 좋은 방법
를 통해
범위 지정 작품 : 당신의 협회가 설정하는 방법에 따라, 당신은이와 Audit.create 비트를 대체 할 더 나은 할 것 params를 복제해야하거나 삭제와 함께 물건을 깨뜨릴 위험이 있습니다! –
좋은 지적! 수정하기 위해 편집 됨. –
필자는 2 년이 지났으나 매개 변수 필터링을 사용하면이 매개 변수가'params'보다 낫다고 알고있다. local_params request.filtered_parameters.dup' –