我做了 git status 命令并得到这个:
# "public/images/wallpaper/wait/1920\321\2051080.jpg"
# public/style.css
Run Code Online (Sandbox Code Playgroud)
为什么有些文件在引号之间?以及如何将它们添加到 .gitignore 中?
我使用Rails 4和spring&spring-commands-rspecgem.这个问题与此有关:默认情况下使用spring
当我跑步时,time rspec我得到5秒钟的东西.如果我跑,time bin/rspec我有2秒钟.如果我跑,time rake -T我得3秒,如果我跑,time bin/rake -T我得到不到一秒钟.
麻烦在哪里?为什么我需要通过bin/binstubs 运行所有命令来解析它们spring.我怎么能避免这种情况?
github的相关问题:https://github.com/jonleighton/spring-commands-rspec/issues/17#issuecomment-43174278
我有一个非常简单的Comment模型:
schema "comments" do
field :content, :string
belongs_to :user, MyApp.User
timestamps
end
Run Code Online (Sandbox Code Playgroud)
我想创建一条新记录,并且希望changeset验证该用户是否存在。我怎样才能做到这一点?
我的 ecto 版本是1.1.8.
我有模块
defmodule There do
import Othermodule, only: [a: 1]
def b do
end
end
Run Code Online (Sandbox Code Playgroud)
a我怎样才能获得函数&的列表b?
我找到了一个很棒的ActionCable宝石,这是SPA的一个很好的解决方案.
我只想要送html,css和js资产,所有其他连接将通过实施ActionCable.交换字符串或整数并不困难,但我如何通过ActionCable登录?
如您所知,rspec支持let其测试.通过预先定义常见变量并在测试之间共享它们,它非常有用并且可以使代码短路.
我该如何调用此功能ExUnit?
我有几张 Ecto 唱片。但我想复制它们(使它们大 100 倍)以播放大量记录。我怎样才能通过 ecto 机制做到这一点?
假设我有一个User模型has_many Post.
我抓了一个用户:
user = Repo.get(User, 1)
Run Code Online (Sandbox Code Playgroud)
现在我想得到这个用户的所有帖子.我找到的唯一解决方案是:
posts = Repo.preload(user, :posts).posts
Run Code Online (Sandbox Code Playgroud)
但它很难看.那有什么简写吗?
我有一个记录ID列表 - [9, 1, 4, 3].
我想从postgresql中检索记录,并希望它们按照此ID列表进行排序.但是当我进行查询时,记录以任意顺序返回:
Ecto.Query.from(r in Record, where: r.id in [9, 1, 4, 3])
|> Repo.all()
|> Enum.map(&Map.get(&1, :id)) # => [4, 9, 1, 3]
Run Code Online (Sandbox Code Playgroud)
如何检索具有相同订单的记录?
我正在尝试更新状态,基于之前的状态(array of objects),新的传入值为fase object.但由于某些原因,它不会发生......
我做错了什么?我的代码:
handleCommentSubmit = (newEmployer) => {
console.log('handleCommentSubmit BEFORE', this.state.employers, newEmployer); // array(5)
this.setState((prevState, newEmployer) => {
employers: prevState.employers + newEmployer
});
console.log('handleCommentSubmit AFTER', this.state.employers); // still array(5)
}
Run Code Online (Sandbox Code Playgroud)
我的日志:
handleCommentSubmit BEFORE (6) [{…}, {…}, {…}, {…}, {…}, {…}], newEmployer: {first_name: "sdfsdf", last_name: "sdfsdf", birth_date: "123123-03-12", salary: "123123123"}
handleCommentSubmit AFTER (6) [{…}, {…}, {…}, {…}, {…}, {…}]
Run Code Online (Sandbox Code Playgroud) elixir ×6
ecto ×4
ruby ×2
actioncable ×1
git ×1
git-status ×1
javascript ×1
reactjs ×1
rvm ×1
spring-gem ×1