根据the documentation,我可以定义在提交创建或更新类型后执行的相同方法:
after_commit :do_foo_bar, :on [:create, :update]
好吧,这段代码导致了我的解析错误:
无法将符号转换为整数
然后我将其更改为:
after_commit :do_foo_bar, :on => [:create, :update]
我没有错误,但没有任何反应!对日志的进一步调查显示了一个沉默和奇怪的错误:
/home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:404: syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
...(transaction_include_action?(:[:create, :update]))
... ^
/home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:412: syntax error, unexpected keyword_end, expecting ')'
/home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:413: syntax error, unexpected $end, expecting ')'
Redirected to http://localhost:3000/people/1
Completed 302 Found in 7491ms (ActiveRecord: 410.6ms)
我该如何正确地做到这一点?