我有一些在我的主目录"点"的文件,我想跟踪与git的-例如.pryrc,.zshrc等我想有这些文件的远程存储库,以便一)有恢复一个简单的方法我配置设置应该因任何原因丢失我的机器; 和b)安全地跟踪在配置更改时我搞砸的事件对文件所做的任何更改.
我最初在主目录中设置了一个git存储库来跟踪它们,并将.gitignore文件配置为忽略除特定白名单文件名之外的每个文件.但是,我意识到我并不是因为在我的主目录中有一个git存储库而感到疯狂,而且在我的终端窗口中看到分支名称"master"也更加分散注意力.我在设置中使用ZSH来在提示符中显示git分支,结果看到我在git存储库中导航到我不希望拥有存储库的目录时,结果令人惊讶和困惑.
我尝试在主文件夹下创建一个配置目录,将其初始化为git存储库,并为所需文件生成符号链接.但是,在添加并提交远程分支仅显示链接的所有内容后,我注意到,而不是文件的实际内容.
实现这一目标的最佳方法是什么?
跑"酿造医生"并得到一些错误.我设法通过以下链接的建议来修复路径问题:如何修改Homebrew的PATH?.
但是,完全丢失了如何处理以下错误:
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/sm/pkg/active/bin/curl-config
/opt/sm/pkg/active/bin/ncurses5-config
/opt/sm/pkg/active/bin/ncursesw5-config
/opt/sm/pkg/active/bin/pkg-config
/opt/sm/pkg/active/bin/xml2-config
/opt/sm/pkg/active/bin/xslt-config
Run Code Online (Sandbox Code Playgroud)
菜鸟.运行OSX.感谢更聪明的Jedis提供的任何帮助......
我收到以下错误,无法弄清楚如何解决它.Stack Overflow上还有一些其他页面可以解决类似的问题,但这些似乎并不适用,或者至少我不够精明,无法解决这个问题.
当我运行authentication_pages_spec时,问题似乎是使用"patch",导致下面的失败.请注意,我已经尝试用"put"替换"patch"并获得相同的结果.
Failures:
1) Authentication authorization for non-signed-in users in the Users controller submitting to the update action
Failure/Error: before { patch user_path(user) }
NoMethodError:
undefined method `patch' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3::Nested_1::Nested_1::Nested_2:0x007fa7e4df1e50>
# ./spec/features/authentication_pages_spec.rb:59:in `block (6 levels) in <top (required)>'
Finished in 0.34392 seconds
2 examples, 1 failure
Run Code Online (Sandbox Code Playgroud)
注意:根据Stack Overflow的讨论和这里引用的博客,我选择将我的spec/requests文件夹更改为spec/features,因为这似乎是Capybara在2.0版之后所要求的.
这是我的Gemfile:源' https : //rubygems.org'ruby'2.0.0'#ruby-gemset = railstutorial_rails_4_0
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'pg', '0.15.1'
gem 'bcrypt-ruby', '3.0.1'
group :development, :test do
gem 'rspec-rails', …Run Code Online (Sandbox Code Playgroud) rspec ruby-on-rails capybara railstutorial.org ruby-on-rails-4
我有一个Bar属于的嵌套资源Foo.我可以成功列出Bar属于任何给定的所有对象Foo.但我也希望能够生成一个视图,其中包含所有Bar项目,无论Foo它们属于哪个对象.
模型结构是:
# app/models/foo.rb
class Foo < ActiveRecord
has_many :bars
end
# app/models/bar.rb
class Bar < ActiveRecord
belongs_to :foo
end
Run Code Online (Sandbox Code Playgroud)
路由定义为:
# config/routes.rb
resources :foos do
resources :bars
end
Run Code Online (Sandbox Code Playgroud)
我从这个配置中获得了预期的路由:
foo_bars GET /foos/:foo_id/bars(.:format) bars#index
POST /foos/:foo_id/bars(.:format) bars#create
new_foo_bar GET /foos/:foo_id/bars/new(.:format) bars#new
edit_bar GET /bars/:id/edit(.:format) bars#edit
bar GET /bars/:id(.:format) bars#show
PATCH /bars/:id(.:format) bars#update
PUT /bars/:id(.:format) bars#update
DELETE /bars/:id(.:format) bars#destroy
foos GET /foos(.:format) foos#index
POST /foos(.:format) foos#create
new_foo GET /foos/new(.:format) …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用Octopress进行部署的Jekyll。我已经在localhost上很好地工作了,但是由于某些原因,当站点在Github Pages上加载时CSS没有被加载。感谢您对理解原因的任何帮助。
当我查看在Github Pages网址上加载的网站时,显示的404错误main.css。启动器列(使用Chrome btw中的开发人员工具)指示这来自index.html文件,位于HTML标题行中:
<link rel="stylesheet" href="/css/main.css">
Run Code Online (Sandbox Code Playgroud)
_site我的本地计算机上目录的树是:
.
??? 2015
? ??? 11
? ??? 09
? ??? another-jekyll-blog.html
? ??? fifth-time-is-the-charm.html
? ??? jekyll-and-octopress-is-this-thing-on.html
??? about
? ??? index.html
??? css
? ??? main.css
??? feed.xml
??? index.html
??? jekyll
??? update
??? 2015
??? 11
??? 09
??? welcome-to-jekyll.html
Run Code Online (Sandbox Code Playgroud)
在站点被推上后,该树与Github存储库中的完全匹配(我使用,jekyll build之后使用octopress deploy)。
当我查看开发人员工具中的“源”选项卡时,对于已部署的站点,树显示为:
[USER].github.io
|-css
| |-main.css
|
|-octo-5
| |-(index)
Run Code Online (Sandbox Code Playgroud)
但是,当我在localhost上查看站点时,站点树为:
localhost:4000
|-css
| |-main.css
|
|-(index)
Run Code Online (Sandbox Code Playgroud)
显然,该问题似乎与在Github …
我有一个模型Foo state_code作为外键.States表是一个(或多或少)静态表,用于保存50个州的代码和名称,以及其他美国邮政编码(例如波多黎各的"PR").我选择使用state_code国家的主键和Foo的外键,而不是像state_id.它对人类更好,并简化了我想调用状态代码的视图逻辑.(编辑 - 只是为了澄清:我并不是说从视图中调用代码来访问模型;我的意思是显示状态@foo.state_code似乎比简单@foo.state.state_code.)
Foo还has_many与模特Bar 有关系.两个模型规范都传递了有效工厂的规范,但出于某种原因,在运行构建Bar实例的功能规范时,由于与之相关的外键问题导致测试爆炸state_code
我得到了所有模型的模型规格,包括有效工厂的测试.但是,每当我尝试为'Bar'创建测试对象时,我都会遇到麻烦.在Foo中使用build爆炸外键错误state_code(尽管事实上Foo工厂明确指定了一个确认在状态中作为state_code存在的值).使用build_stubbed了Bar对象似乎并不持久化对象.
型号:
# models/foo.rb
class Foo < ActiveRecord
belongs_to :state, foreign_key: 'state_code', primary_key: 'state_code'
has_many :bars
validates :state_code, presence: true, length: { is: 2 }
# other code omitted...
end
# models/state.rb
class State < ActiveRecord
self.primary_key = 'state_code'
has_many :foos, foreign_key: 'state_code'
validates :state_code, presence: true, uniqueness: true, length: { is: 2 }
# …Run Code Online (Sandbox Code Playgroud) 我很困惑需要安装哪些宝石才能在Rails 4.2项目中正确运行Pry.直到最近我似乎都很好.出于某种原因,binding.pry现在看来咯出每当我试图通过一个控制台会话步骤next,step在命令行,等等.它将抛出一个丑陋的堆栈跟踪,然后在代码中向我显示相同的点,而不会进一步踩踏.在第二个next命令之后,它会抛出相同的堆栈跟踪并退出,从而将执行返回到localhost服务器.我在浏览器页面上遇到运行时错误No frames collected.
如果我binding.pry在我的代码中注释掉,一切正常.所以我强烈怀疑我的Pry配置有问题.似乎Pry有几十种变体,没有明确的指导应该安装哪一个,哪些可能会发生冲突,等等.
这是next代码到达binding.pry调用后在Pry控制台中调用时得到的堆栈跟踪:
From: /Users/me/sites/arailsapp/app/controllers/bars_controller.rb @ line 31 BarsController#edit:
29: def edit
30: binding.pry
=> 31: @bar = Bar.find(params[:id])
32: @foo = @bar.foo
33: end
[6] pry(#<BarsController>)> n
Completed 500 Internal Server Error in 2685ms (ActiveRecord: 0.0ms)
RuntimeError - No frames collected.:
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:122:in `perform_next'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:60:in `perform'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:49:in `run'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:111:in `resume_pry'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:69:in …Run Code Online (Sandbox Code Playgroud) 在开发和生产中使用Postgres 9.4运行Rails 4.我有一张随着时间的推移而逐渐迁移的大桌子.由于表中有许多不同的列,我想重新排序,以便更加逻辑地对列进行分组.换句话说,一些列元素基于它们捕获的信息自然地组合在一起.
在此堆栈溢出讨论中,我发现了有关在after:迁移中使用以重新排序列(ALTER TABLE在SQL中使用)的讨论.然后我继续设置迁移来做到这一点.运行迁移后,我注意到我的schema.rb文件没有更改.查看数据库中的列(开发后的postgres),也没有任何改变.
进一步的研究使我进入了Postgres维基,该维基表示目前不支持改变Postgres的柱位.
这不是关键任务,但它会让生活更轻松.我的问题是:
如果我只是schema.rb向上或向下移动文件中的行以便根据需要定位它们,那会导致任何问题吗?因为我希望使用rake db:schema:load来配置任何新数据库,所以看起来不应该破坏任何东西.此外,由于以前的迁移没有实质性改变(只是它们输出到schema.rb的列的顺序),一切都应该是内部一致的,不是吗?
如果这是一个坏主意,我可以简单地回到早期的迁移,为after: :some_column每个列元素添加语法,以便他们正确设置schema.rb文件?
我的假设是,当我从头开始使用种子数据重建我的生产数据库时,它将使用模式结构以所需顺序正确创建表.现在它不是一个真正的,部署了最终用户的数据库,所以它似乎不是一个问题.使用上面的选项#1似乎是最简单的解决方案,只要它不会破坏任何东西.
rspec ×2
capybara ×1
debugging ×1
dotfiles ×1
factory-bot ×1
git ×1
github-pages ×1
homebrew ×1
jekyll ×1
macos ×1
path ×1
postgresql ×1
pry ×1
pry-rails ×1