什么是使这个实际上异步发布的正确咒语?
form_tag :controller => :magic, :action => :search, :method => post, :remote => true do
Run Code Online (Sandbox Code Playgroud)
method = post和remote = true只是在url的末尾被压扁而不是实际上使它成为ajax帖子.
我将在命名范围中放入什么:by_unique_users以便我可以执行Comment.recent.by_unique_users.limit(3),并且每个用户只能获得一条评论?
class User
has_many :comments
end
class Comment
belongs_to :user
named_scope :recent, :order => 'comments.created_at DESC'
named_scope :limit, lambda { |limit| {:limit => limit}}
named_scope :by_unique_users
end
Run Code Online (Sandbox Code Playgroud)
在sqlite named_scope:by_unique_user,:group =>"user_id"工作,
但是它会在postgres上出现问题,postgres部署在生产PGError:ERROR:列"comments.id"必须出现在GROUP BY子句中或用于聚合函数