- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
预先感谢您的帮助!
我刚刚完成了 Rails 教程的第 6 章:
http://ruby.railstutorial.org/chapters/modeling-users#sec-6_4
我跑了:
❤ git checkout master
❤ git merge modeling-users
Updating fc9f72a..90d1ba6
error: The following untracked working tree files would be overwritten by merge:
app/models/user.rb
Please move or remove them before you can merge.
Aborting
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation
has_secure_password
before_save { |user| user.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 }
validates :password_confirmation, presence: true
end
Unable to save ~/code/rails_projects/sample_app/spec/models/user_spec.rb
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
require 'spec_helper'
describe User do
before do
@user = User.new(name: "Example User", email: "user@example.com",
password: "foobar", password_confirmation: "foobar")
end
subject { @user }
it { should respond_to(:name) }
it { should respond_to(:email) }
it { should respond_to(:password_digest) }
it { should respond_to(:password) }
it { should respond_to(:password_confirmation) }
it { should respond_to(:authenticate) }
it { should be_valid }
describe "when name is not present" do
before { @user.name = " " * 51 }
it { should_not be_valid }
end
describe "when email format is valid" do
it "should be valid" do
addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@bax.cn]
addresses.each do |valid_address|
@user.email = valid_address
@user.should be_valid
end
end
end
describe "when email format is valid" do
it "should be valid" do
addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@baz.cn]
addresses.each do |valid_address|
@user.email = valid_address
@user.should be_valid
end
end
end
describe "when email address is already taken" do
before do
user_with_same_email = @user.dup
user_with_same_email.email = @user.email.upcase
user_with_same_email.save
end
it { should_not be_valid }
end
describe "when password is not present" do
before { @user.password = @user.password_confirmation = " " }
it { should_not be_valid }
end
describe "when password doesn't match confirmation" do
before { @user.password_confirmation = "mismatch" }
it { should_not be_valid }
end
describe "when password confirmation is nil" do
before { @user.password_confirmation = nil }
it { should_not be_valid }
end
describe "with a password that's too short" do
before { @user.password = @user.password_confirmation = "a" * 5 }
it { should be_invalid }
end
describe "return value of authenticate method" do
before { @user.save }
let(:found_user) { User.find_by_email(@user.email) }
describe "with valid password" do
it { should == found_user.authenticate(@user.password) }
end
describe "with invalid password" do
let(:user_for_invalid_password) { found_user.authenticate("invalid") }
it { should_not == user_for_invalid_password }
specify { user_for_invalid_password.should be_false }
end
end
end
require 'spec_helper'
describe ApplicationHelper do
describe "full_title" do
it "should include the page title" do
full_title("foo").should =~ /foo/
end
it "should include the base title" do
full_title("foo").should =~ /^Ruby on Rails Tutorial Sample App/
end
it "should not include a bar for the home page" do
full_title("").should_not =~ /\|/
end
end
end
最佳答案
错误 The following untracked working tree files would be overwritten by merge
正在发生是因为有一个 app/models/user.rb
当前未添加到任何分支的文件夹中的文件。
您可以通过运行 git status
来验证这一点。命令;它应该显示类似于以下内容的输出:
$ git status
# On branch master
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# app/models/user.rb
no changes added to commit (use "git add" and/or "git commit -a")
git merge modeling-users
,它正在尝试合并
modeling-users
分支到
master
分支。
modeling-users
分支已经有
app/models/user.rb
的副本包含在其中。合并命令使它覆盖文件的未跟踪版本,而该版本已经在
modeling-users
中。分支。因此,错误消息会警告您可能会丢失您想要保留的东西。
git status
消息指示,通过运行
git add app/models/user.rb
将文件添加到 master 分支命令。
Unable to save ~/code/rails_projects/sample_app/spec/models/user_spec.rb
消息似乎与此无关。从错误消息中不能做太多;也许其他地方有更多信息。
关于git-merge - 错误 : The following untracked working tree files would be overwritten by merge:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14696872/
当我推送覆盖现有图像(名称和标签相同)的新图像时,先前的图像只是从其标签中删除,并保留在存储库中。 有没有一种方法可以配置gcr或我的docker命令,使其不保留过期的镜像?我可以查询没有标签的图像并
假设我有atomic i;线程 A 使用 memory_order_release 执行原子存储/交换。接下来,线程 B 使用 memory_order_release 执行原子存储。线程 C 执行原
从基于团队的 Git 远程存储库中 pull 时,我收到此消息: "C:\Program Files (x86)\Git\bin\git.exe" pull --progress "origin" +
问题:由于此错误,我无法在本地启动区块链-突然 pop 。恐怕由于项目原因,我将无法共享很多代码。 背景:昨天早晨出现错误时,没有特别的更改。当我开始工作时,我只是尝试启动本地区块链,这使此错误出现:
当一个类扩展另一个类时,它继承父类(super class)的所有方法和变量。如果您在具有相同签名的子类中以不同方式定义方法和变量,则它们可以在子类中以不同方式使用。现在 Oracle 区分覆盖和隐藏
这是我的 Python 脚本与 XLSXwriter 遵循的基本流程: 创建工作簿 创建工作表 定义格式 在第 1 行中写入列标题(利用第 3 步中的格式设置) 在后续行中写入实际数据(无特殊格式)
我正在写入 hadoop 文件系统。但是每次我追加一些东西时,它都会覆盖数据而不是将其添加到现有数据/文件中。下面提供了执行此操作的代码。针对不同的数据一次又一次地调用此代码。每次打开一个新的 Seq
我有一个名为ggstatsplot(https://indrajeetpatil.github.io/ggstatsplot/)的R包,它依赖于彼此共享一些S3方法的包的集合。因此,每次加载程序包时,
我被这个问题难住了,也许你可以帮助我。 这是我的 html: All products cat 1 cat 2 这是我的 js: jQuery(".wpsc_product_list_categ
项目: 获取维基百科的罗马执政官列表,将数据放入 CSV 文件中,这样我就可以制作一张关于领事权方面各氏族兴衰的图表 示例数据源: 509,L. Iunius Brutus,L. Tarquinius
我是计算和计算机领域的新手..我正在使用C编程进行开发,每次我陷入思考时,如果我们用新值修改它,PC如何真正删除旧值,我的意思是:假设我在 C 上这样写 int i=6; i=7; 那么 i 的值为
假设我有如下模块: app-core app-db app-ui app app 模块包括所有其他 3 个模块。比方说,除了 app 之外的所有模块都定义了一个名为 app_name 的字符串。哪一个
我正在尝试使用一个小的 from,只有 3 个元素。这是我正在使用的,有人可以让我知道我哪里出错了吗?我已尝试同时使用最小宽度和最大宽度,但似乎没有任何效果。 html,body{margin:0p
所以,我的带有颜色 !important 的 id 选择器被一个没有 !important 的简单 .class h1 选择器覆盖。我很困惑,无法找到这方面的任何信息。 我知道 css 的特殊性,无论
我刚刚安装了 CKEditor 3.0。一切正常,除了编辑器的风格。因为在这个最新版本中,WYSIWYG 按钮放在网站上(而不是在框架中),所以我的样式表覆盖了 CKEditor 按钮。我的样式表
背景 我只使用一个分支 - master。 3---------2--------- | 6-------5---------4
升级Flutter SDK和包 My-Mac:~ admin$ flutter upgrade Upgrading Flutter from /Users/admin/Desktop/
我在 youtube 上关注了 React JS Crash Course - 2019,但无法找到以下问题的答案。 为什么子组件的绑定(bind)调用不会覆盖父组件中的方法上下文。 可以在此处找到代
在我的应用中,提交按钮和链接看起来完全一样。 我构建我的 css 的方式是这样的: .button, input[type=submit]{ //default colour back
一些说明: 我想在游戏中有 6 个占位符 div 用于罢工。 就像[ ] [ ] [ ] [ ] [ ] [ ]。 这将是带有黑色边框的白色方 block 。 在他们猜错之后,我希望第一个 div 被
我是一名优秀的程序员,十分优秀!