在我的应用程序中,Conversation有很多消息.如何updated_at在创建/保存该对话中的新消息时更新对话的属性?
我知道:touch => true,这样做,但它也会在消息被销毁时更新对话,这不是我想要的.
谢谢.
楷模
class Conversation < ActiveRecord::Base
has_many :messages
end
class Message < ActiveRecord::Base
belongs_to :conversation
end
Run Code Online (Sandbox Code Playgroud) 我想在d3中可视化20K节点依赖图.强制导向的图形(例如http://bl.ocks.org/mbostock/1153292)太慢而无法在浏览器中呈现此数量的节点.
基本上我想表示包含从一个节点到另一个节点的文本和有向边的节点,并添加缩放和平移功能.我怎样才能在d3中这样做?

我有一个带有索引的单词表(language_id,state).以下是EXPLAIN ANALYZE的结果:
没有限制
explain analyze SELECT "words".* FROM "words" WHERE (words.language_id = 27) AND (state IS NULL);
Bitmap Heap Scan on words (cost=10800.38..134324.10 rows=441257 width=96) (actual time=233.257..416.026 rows=540556 loops=1)
Recheck Cond: ((language_id = 27) AND (state IS NULL))
-> Bitmap Index Scan on ls (cost=0.00..10690.07 rows=441257 width=0) (actual time=230.849..230.849 rows=540556 loops=1)
Index Cond: ((language_id = 27) AND (state IS NULL))
Total runtime: 460.277 ms
(5 rows)
Run Code Online (Sandbox Code Playgroud)
限制100
explain analyze SELECT "words".* FROM "words" WHERE (words.language_id = 27) AND (state IS …Run Code Online (Sandbox Code Playgroud) 我的文档结构如下:
{_id: 1, country: 'USA', names: [{language: 'en', name: 'New York', state:'new'}, {language: 'es', name: 'Nueva York', state:'translated'}]}
{_id: 2, country: 'France', names: [{language: 'en', name: 'Paris', state:'new'}, {language: 'it', name: 'Parigi', state:'translated'}]}
...
Run Code Online (Sandbox Code Playgroud)
我想更新特定语言的项目状态,如果该语言不存在,则添加相应的嵌入文档。例如,我想更新要设置的项目 1 state='new',language='es'因为该语言存在:
{_id: 1, country: 'USA', names: [{language: 'en', name: 'New York', state:'new'}, {language: 'es', name: 'Nueva York', state:'translated'}]}
Run Code Online (Sandbox Code Playgroud)
我想将嵌入的文档添加到第 2 项state='new',language='fr'因为它不存在:
{_id: 2, country: 'France', names: [{language: 'en', name: 'Paris', state:'new'}, {language: 'it', name: 'Parigi', state:'translated'}, {language: …Run Code Online (Sandbox Code Playgroud) 如何在8台计算机上运行的Rails应用程序(负载平衡)上运行Paperclip图像上传?
用户可以在应用程序上上传图像.图像存储在其中一台机器上.用户稍后请求图像,但是找不到图像,因为它是从另一台机器请求的.
这类问题的解决方法是什么?我无法使用AWS或任何云服务; 图像必须存储在内部.
谢谢.
在我的应用中,用户有很多对话,而对话有很多消息.我在逻辑上构建了我的资源如下:
resources :users do
resources :conversations do
resources :messages
end
end
Run Code Online (Sandbox Code Playgroud)
对我来说,这是一个逻辑结构.但建议不要将资源嵌套超过1级.
那么,我应该将Conversations作为独立资源还是继续打破指南?每种方法的全球优势和缺点是什么?
谢谢.
我正在将模糊过渡应用到页面的主体
body
transition(all 1s)
&.blurred
pointer-events none
transition(all 1s)
-webkit-filter blur(5px)
Run Code Online (Sandbox Code Playgroud)
当我将模糊的类添加到正文时,Chrome会闪烁,而Safari则不会.
添加-webkit-backface-visibility: hidden并不能解决这个问题.它似乎消除了第一个闪烁,但Chrome在应用模糊后仍然闪烁,特别是如果body包含大量内容/ div.
有没有办法达到同样的效果,没有闪烁?
在我的应用中,用户有很多对话,而对话有很多消息.我想创建一个新的对话:我必须指定用户(读者)和(第一个)消息.我试过以下,但失败了.
楷模
class Conversation < ActiveRecord::Base
has_many :conversation_users
has_many :users, :through => :conversation_users
has_many :messages
accepts_nested_attributes_for :users
accepts_nested_attributes_for :messages
end
class Message < ActiveRecord::Base
belongs_to :conversation
belongs_to :user
end
class User < ActiveRecord::Base
has_many :conversation_users
has_many :conversations, :through => :conversation_users
end
Run Code Online (Sandbox Code Playgroud)
调节器
def new
@conversation = Conversation.new
2.times do
users = @conversation.users.build
end
messages = @conversation.messages.build
end
def create
@conversation = Conversation.new(params[:conversation])
if @conversation.save
redirect_to username_conversations_path(current_username)
else
redirect_to new_username_conversation_path(current_username)
end
end
Run Code Online (Sandbox Code Playgroud)
视图
<% form_for([current_user, @conversation]) do |f| %>
<% f.fields_for …Run Code Online (Sandbox Code Playgroud) 我的数据库结构如下:
{ title : "My First Post", author: "Jane",
comments : [{ by: "Abe", text: "First" },
{ by : "Ada", text : "Good post" } ]
}
Run Code Online (Sandbox Code Playgroud)
我无法写出以下内容:
post变量中后,显示Abe的评论文本谢谢.
mongodb ×2
node.js ×2
css ×1
d3.js ×1
graph ×1
html ×1
image ×1
indexing ×1
javascript ×1
paperclip ×1
postgresql ×1
scalability ×1
sql ×1