0

根据文档,我可以定义在创建或更新类型的提交后执行的相同方法:

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)

我怎样才能正确地做到这一点?

4

1 回答 1

1

我认为您使用的 Rails 版本在回调中不支持此功能。检查下面的功能请求

https://github.com/rails/rails/pull/9356

于 2013-09-04T00:09:06.097 回答