如何为新模型创建一个带有id的固定链接?name: 'cool dog') #creates animal with id of 1 and name of dog
如何添加正确的回调以插入update_permalink #or before_save
self.permalink = "#{id} #{name}".parameterize
在他们的文档上:
这里的# if persist successful, database update not guaranteed是什么意思?有人能解释before_success和成功挂钩的区别吗?如果要在这些钩子上修改同一个ActiveRecord对象的属性,是否必须调用ActiveRecord?谢谢
与有关,但我认为有必要提出自己的问题。如果我有这样的代码:MyModel.transaction do my_instance.saveendputs new_instance.foo
这是否保证new_instance.foo总是输出"bar“而不是其先前的值?我正在寻找一种方法,以确保在执行下一个语句之前,所有发生在前一个语句