Ruby on Rails 3 - 回调不再起作用
大家好。
我有一个大问题。直到两周前,我的代码工作正常,但今天我意识到一些回调不再工作。
回调如下:
class DetailPurchase < ActiveRecord::Base
belongs_to :purchase, :foreign_key => 'purchase_id'
belongs_to :product, :foreign_key => 'product_id'
belongs_to :buy_order_detail, :foreign_key => 'buy_detail_id'
def before_create
Storage.create!(:product_id => self.product_id, :current_quantity => self.quantity, :stg_data => purchase.prc_data)
end
end
其想法是,每次创建 Detail_purhase 时,都应自动创建具有相同产品的存储。
但现在它不起作用,唯一的变化是现在我使用 jquery 而不是 prototype
这可能是问题所在吗?
Hi people.
I have a big problem. Untill 2 weeks ago, my code was working fine, but today I realize that some callbacks are not working any more.
The callback is the following:
class DetailPurchase < ActiveRecord::Base
belongs_to :purchase, :foreign_key => 'purchase_id'
belongs_to :product, :foreign_key => 'product_id'
belongs_to :buy_order_detail, :foreign_key => 'buy_detail_id'
def before_create
Storage.create!(:product_id => self.product_id, :current_quantity => self.quantity, :stg_data => purchase.prc_data)
end
end
The idea is that everytime a Detail_purhase is created, a storage with the same product should be created automatically after that.
But now it is not working, the only change is now I'm using jquery instead of prototype
Could that be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
奇怪的是它起作用了。正确的语法是:
Weird it worked. Correct syntax is: