Ruby on rails 在多个操作上提交后的Rails3 ActiveRecord事务
根据,我可以定义在create或update类型的提交之后要执行的相同方法:Ruby on rails 在多个操作上提交后的Rails3 ActiveRecord事务,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,根据,我可以定义在create或update类型的提交之后要执行的相同方法: after_commit :do_foo_bar, :on [:create, :update] 这段代码会导致我的解析错误: 无法将符号转换为整数 然后我将其更改为: after_commit :do_foo_bar, :on => [:create, :update] 我没有出错,但什么也没发生!对日志的进一步调查显示,出现了一个无声且奇怪的错误: /home/nuno/.rvm/gems/ruby-1.
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)
如何正确地执行此操作?我认为您使用的Rails版本在回调中不支持此功能。检查下面的功能请求
提交后重试:do\u foo\u bar,:on=>[“创建”,“更新”]@Raghu相同的结果。。。