我想用meld来查看修订版之间的区别.我安装了meld然后在项目目录中执行:
svn diff -r 2165:2182 --diff-cmd meld
Run Code Online (Sandbox Code Playgroud)
但它引发了以下错误:
Index: app/models/college_friends_count.rb
===================================================================
svn: E200012: Process 'meld' failed (exitwhy 2)
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这里出了什么问题?
当我执行时%rake college:create[demo]
,我收到以下错误,
zsh: no matches found: college:create[demo]
Run Code Online (Sandbox Code Playgroud)
有人有解决方案吗?
当我执行时rake -T
,这是我作为输出行之一得到的:
rake college:create[config_name] # create a college profile
Run Code Online (Sandbox Code Playgroud)
因此,它是一个有效的命令,但仍然zsh显示错误.
我有三节课
class Post
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :user, :inverse_of => nil
embeds_many :comments, :as => :commentable
field :content, :type => String
end
class Commment
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :user, :inverse_of => nil
embedded_in :commentable, :polymoriphic => true
end
class User
has_many :posts, :dependent => :destroy
field :name, :type => String
end
Run Code Online (Sandbox Code Playgroud)
每当用户创建新评论时,我想将其内容与用户所做的最新评论进行比较.这是我的代码,用于获取用户的最新评论:
comments_user=[]
Post.where("comments.user_id" => user.id).
only(:comments).
each {|p| comments_user += p.comments.where(:user_id => user.id).to_a}
latest_comment = comments_user.sort_by{|comment| comment[:updated_at]}.reverse.first
Run Code Online (Sandbox Code Playgroud)
上面的代码给了我结果,但所采用的方法效率不高,因为我必须遍历用户已经提交的所有帖子以找到最新的评论.如果有的话,任何人都可以为我提供更有效的解决方案吗?简单来说,我有没有办法得到这个用户的所有评论?
我有以下列表:
l = [
%{id: 1, name: "aash", possess: "car"},
%{id: 1, name: "aash", possess: "bike"},
%{id: 2, name: "rahul", possess: "scooter"}
]
Run Code Online (Sandbox Code Playgroud)
我想将其转换为以下格式:
ans = [
%{id: 1, name: "aash", possess: ["car", "bike"]},
%{id: 2, name: "rahul", possess: ["scooter"]}
]
Run Code Online (Sandbox Code Playgroud)
关于如何在灵药中做到这一点的任何想法?由于所有变量都是不可变的,我不知道如何实现上述转换.