我有一篇文章。
当发表评论时,我可以使用“新”来积累这些评论,而评论记录只是在保留条款时才制作。
是否有这样的机制对删除的评论意见进行标识,因此只有在挽救了该条款时才能删除其记录?
感谢。
我有一篇文章。
当发表评论时,我可以使用“新”来积累这些评论,而评论记录只是在保留条款时才制作。
是否有这样的机制对删除的评论意见进行标识,因此只有在挽救了该条款时才能删除其记录?
感谢。
我建议你熟悉#accepts_nested_attributes_for。 例如,你想要的是什么。 这是改写的:
class Post < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments, :allow_destroy => true
end
post = Post.find(1) # With 3 comments
post.comments_attributes = [{:_destroy => "1", :id => post.comments.first.id}]
# Look ma! No SQL statements!
post.save!
# BEGIN / UPDATE posts / DELETE FROM comments WHERE id = X / COMMIT
在交易中:
Article.transaction do
...
end
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...
As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...