Hi
a) I installed the acts_as_audited plugin (which works in Prorduction
Mode only) and activated it with only 1 line of code at application.rb
audit User,Customer,Receivables
b) In my customer Controller I have
config.nested.add_link("Receivables", [:receivables])
c) Works perfectly (ie changes captured in the Audits table) until I
tried to access one of the nested tables (ie Receivables) on AS and I
consistently got this error message
NoMethodError (undefined method `controller_name' for nil:NilClass):
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/caching.rb:602:in `callback'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/caching.rb:595:in `after'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:602:in `proxy_before_and_after_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:470:in `call'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:470:in `call'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:637:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:638:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:438:in `call'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:637:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:638:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:438:in `call'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:637:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:638:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:449:in `call'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:637:in `call_filter'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/filters.rb:619:in `perform_action_without_benchmark'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/benchmarking.rb:66:in
`perform_action_without_rescue'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/rescue.rb:83:in `perform_action'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `send'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/base.rb:430:in `process_without_filters'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/filters.rb:624:in
`process_without_session_management_support'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
action_controller/session_management.rb:114:in `process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack- 1.13.3/lib/
action_controller/base.rb:330:in `process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
dispatcher.rb:41:in `dispatch'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
lib/mongrel/rails.rb:78:in `process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `synchronize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
lib/mongrel/rails.rb:76:in `process'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:618:in `process_client'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
lib/mongrel.rb:617:in `each'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:617:in `process_client'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
lib/mongrel.rb:736:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `initialize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
lib/mongrel.rb:736:in `new'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:736:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32 /
lib/mongrel.rb:720:in `initialize'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel.rb:720:in `new'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32 /
lib/mongrel.rb:720:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:271:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32 /
lib/mongrel/configurator.rb:270:in `each'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/configurator.rb:270:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
bin/mongrel_rails:127:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
lib/mongrel/command.rb:211:in `run'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel- 1.0.1-mswin32/
bin/mongrel_rails:243
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/active_support/dependencies.rb:488:in `load'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.4.2/
lib/active_support/dependencies.rb:488:in `load'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/active_support/dependencies.rb:342:in `new_constants_in'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.4.2/
lib/active_support/dependencies.rb:488:in `load'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/servers/mongrel.rb:60
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require'
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.4.2/
lib/active_support/dependencies.rb:495:in `require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
lib/active_support/dependencies.rb:342:in `new_constants_in'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.4.2/
lib/active_support/dependencies.rb:495:in `require'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
commands/server.rb:39
C:/antRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require'
./script/server:3
-e:4:in `load'
-e:4
Rendering C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/
actionpack-1.13.3/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)
Any ideas how to workaround this problem ?
On Aug 28, 5:25 am, "Blake B" <sha...@gmail.com> wrote:
> I ran into this as well. It's only a problem with caching enabled, and I
> found that if you comment out line # 602 in
> vendor/rails/actionpack/lib/action_controller/filters.rb then it works, but
cch: Err.. I don't have rails under my vendor directory
BTW,after dsabling cache,was acts_as_audited still capturing the audit
trail ?
> obviously this probably has ripple-effects for caching.
>
> If you find out anything more, I'd love to hear it.
cch:I will keep you postedon this group
>
> -Blake
>
> On 8/23/07, CCH <c...@karensoft.com.my> wrote:
>
>
>
>
>
> > Hi
>
> > a) I installed the acts_as_audited plugin (which works in Prorduction
> > Mode only) and activated it with only 1 line of code at application.rb
>
> > audit User,Customer,Receivables
>
> > b) In my customer Controller I have
>
> > config.nested.add_link("Receivables", [:receivables])
>
> > c) Works perfectly (ie changes captured in the Audits table) until I
> > tried to access one of the nested tables (ie Receivables) on AS and I
> > consistently got this error message
>
> > NoMethodError (undefined method `controller_name' for nil:NilClass):
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/caching.rb:602:in `callback'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/caching.rb:595:in `after'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:602:in `proxy_before_and_after_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:470:in `call'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:470:in `call'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:637:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:638:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:438:in `call'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:637:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:638:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:438:in `call'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:637:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > action_controller/filters.rb:638:in `call_filter'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/
> > lib/mongrel.rb:736:in `run'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
> > lib/active_support/dependencies.rb:342:in `new_constants_in'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
> > lib/active_support/dependencies.rb:488:in `load'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
> > commands/servers/mongrel.rb:60
> > C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `gem_original_require'
> > C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `require'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
> > lib/active_support/dependencies.rb:495:in `require'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
> > lib/active_support/dependencies.rb:342:in `new_constants_in'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/
> > lib/active_support/dependencies.rb:495:in `require'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/
> > commands/server.rb:39
> > C:/antRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> > 27:in `gem_original_require'
> > C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/
> > custom_require.rb:27:in `require'
> > ./script/server:3
> > -e:4:in `load'
> > -e:4
>
> > Rendering C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/
> > actionpack-1.13.3/lib/action_controller/templates/rescues/layout.rhtml
> > (500 Internal Error)
>
> > Any ideas how to workaround this problem ?- Hide quoted text -
>
> - Show quoted text -
Hi Blake
On Aug 28, 5:25 am, "Blake B" <sha...@gmail.com> wrote:
> I ran into this as well. It's only a problem with caching enabled, and I
> found that if you comment out line # 602 in
> vendor/rails/actionpack/lib/action_controller/filters.rb then it works, but
cch: Err.. I don't have rails under my vendor directory
BTW,after dsabling cache,was acts_as_audited still capturing the audit
trail ?
> obviously this probably has ripple-effects for caching.
>
> If you find out anything more, I'd love to hear it.
cch:I will keep you postedon this group
Have given up on acts_as_audited...
Just got an idea from Rails Recipes by Chad Fowler and have written my
own version which actually works and does not give any problem to
accessing of AS Nested Controllers. I am able to easily capture the
audit trail of goldberg user, record_id, record_type, event (CRUD),
created_at.
Using only one audit_trail table, I can even specify which model to
audit.
What I need to do now is to figure out how to serialize (the changes
to model's data ) into YAML by Active Record
Any insight into the serialization (into YAML) by Active Record is
appreciated.
Intriguing...
Can you give a more comprehensive example
My AuditSweeper.rb is as follows :-
class AuditSweeper < ActionController::Caching::Sweeper
# modules to be audited
observe
Customer,Contact,Engactua,Conactua,Workplan,Todolist,Vacation,Incident,Disbursement,Receivable,Payable,Far4staff,Productgroup,Mktpipeline,Wipbill,Projsma,Quotation
def after_destroy(record)
log(record, "DESTROY")
end
def after_update(record)
log(record, "UPDATE")
end
def after_create(record)
log(record, "CREATE")
end
def log(record, event, user = controller.session[:user],
username=current_user.login)
AuditTrail.create(:record_id => record.id, :record_type =>
record.type.name,
:event => event, :user_id
=>user, :name=>username)
end
end
Where and how should I add the serializing codes ?
> > > -Blake- Hide quoted text -
I was wrong, using my own version of auditing also did not work with
nested controllers.
Using acts_as_audited, the moment it is activated, all modules with
nexted controllers wil get a 500 error when you try to access a nested
controller.
With my version, there was some improvement in that only controllers
with nested controlers marked for auditing will be affected.
The bottomline would be that nested controllers in AS simply don't
work if it is being observed.
Ed, I understand from the AS Homepage that nested controllers is your
area of expertise, can you point me in the right direction...
> > -Blake- Hide quoted text -
So, acts_as_audited and nested controllers are not playing nice. To be
honest I have no experience with acts_as_audited but I did notice that
it uses polymorphic associations. There are several issues with
polymorphic associations in the issue list, unfortunately they are all
still open. One issue is slated to be fixed for the 1.1 release.
Ed.
On Sep 14, 9:55 pm, Ed Moss <edwin.m...@gmail.com> wrote:
> Did I hear my name?
cch: Yup !
>
> So, acts_as_audited and nested controllers are not playing nice. To be
> honest I have no experience with acts_as_audited but I did notice that
> it uses polymorphic associations. There are several issues with
> polymorphic associations in the issue list, unfortunately they are all
> still open. One issue is slated to be fixed for the 1.1 release.
cch
My alternative to acts_as_audited still had similar issues .
Perhaps, you can take a look at my simple auditsweer to see how it is
interfering with the nested controllers.
My AuditSweeper.rb is as follows :-
class AuditSweeper < ActionController::Caching::Sweeper
# modules to be audited
observe
Customer,Contact,Engactua,Conactua,Workplan,Todolist,Vacation,Incident,Disb
ursement,Receivable,Payable,Far4staff,Productgroup,Mktpipeline,Wipbill,Proj
sma,Quotation
def after_destroy(record)
log(record, "DESTROY")
end
def after_update(record)
log(record, "UPDATE")
end
def after_create(record)
log(record, "CREATE")
end
def log(record, event, user = controller.session[:user],
username=current_user.login)
AuditTrail.create(:record_id => record.id, :record_type =>
record.type.name,
:event => event, :user_id
=>user, :name=>username)
end
end
TIA
> > > - Show quoted text -- Hide quoted text -
Issue now closed with a tip I got from Dubek on 6 Nov 2007.
It is as simple as
cache_sweeper :audit_sweeper, :only => [:update, :create, :destroy]