我经常在Gemfile中看到以下符号(〜>).
gem "cucumber", "~>0.8.5"
gem "rspec", "~>1.3.0"
Run Code Online (Sandbox Code Playgroud)
我知道符号(> =)只是大于或等于,但(〜>)符号是什么意思?它们是相同的还是有任何显着差异?
我环顾四周如何改变动态params插槽,并发现这篇文章确实完成了.该帖子是http://robots.thoughtbot.com/post/159809070/rails-patch-change-the-name-of-the-id-parameter-in
基本上它的作用是,如果以下是路线:
map.resources :clients, :key => :client_name do |client|
client.resources :sites, :key => :name do |site|
site.resources :articles, :key => :title
end
end
Run Code Online (Sandbox Code Playgroud)
这些路由创建以下路径:
/clients/:client_name
/clients/:client_name/sites/:name
/clients/:client_name/sites/:site_name/articles/:title
Run Code Online (Sandbox Code Playgroud)
一种解决方案是覆盖def to_param模型中的方法,但我希望这不触及模型本身.
但是自从它为Rails 2.x以来,我怎样才能为Rails 3实现相同的功能呢?
更新
这个程序是使用Mongoid.不是AR.所以,友好的宝石不能用于afaik.
我想删除石墨的存储耳语数据,但石墨文档中没有任何内容.
我做的一种方法是/opt/graphite...../whispers/stats...手动删除文件.
但这很乏味,所以我该怎么做?
以下是我的回购的状态.
[~/rails_apps/jekyll_apps/nepalonrails (design)?] ? gst
# On branch design
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: _layouts/default.html
# deleted: _site/blog/2010/04/07/welcome-to-niraj-blog/index.html
# deleted: _site/blog/2010/04/08/the-code-syntax-highlight/index.html
# deleted: _site/blog/2010/05/01/showing-demo-to-kalyan/index.html
# deleted: _site/config.ru
# deleted: _site/index.html
# deleted: _site/static/css/style.css
# deleted: _site/static/css/syntax.css
# modified: static/css/style.css
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
我突然做了git …
我一直在使用git,但仍然对.gitignore文件路径感到困惑.
那么,.gitignore文件中以下两个路径之间有什么区别?
tmp/* public/documents/**/*
我可以理解,tmp/*它将忽略其中的所有文件和文件夹.我对吗?但是第二条线路的意思是什么?
我用谷歌搜索了所有其他人,但我找不到答案.问题是:
嗨,我怎么能用Mongoid批量插入到MongoDB?
我已经在1月2日的AWS官方论坛上问了这个,但没有回复.所以,我再次在这里发布它,以便我可以修复错误.
我安装了awscli,如本页所述http://docs.amazonwebservices.com/cli/latest/userguide/cli-chap-getting-started.html
以下是安装细节:
millisami at millisami in ~/Code/face_tester on design ?
± which python
/usr/local/bin/python
millisami at millisami in ~/Code/face_tester on design ?
± python --version
Python 2.7.3
millisami at millisami in ~/Code/face_tester on design ?
± pip install awscli --upgrade
Requirement already up-to-date: awscli in /usr/local/lib/python2.7/site-packages
Requirement already up-to-date: botocore>=0.4.0 in /usr/local/lib/python2.7/site-packages/botocore-0.4.1-py2.7.egg (from awscli)
Requirement already up-to-date: six>=1.1.0 in /usr/local/lib/python2.7/site-packages/six-1.2.0-py2.7.egg (from awscli)
Requirement already up-to-date: argparse>=1.1 in /usr/local/lib/python2.7/site-packages/argparse-1.2.1-py2.7.egg (from awscli)
Requirement already up-to-date: requests>=0.12.1,<1.0.0 in /usr/local/lib/python2.7/site-packages/requests-0.14.2-py2.7.egg (from botocore>=0.4.0->awscli) …Run Code Online (Sandbox Code Playgroud) 以前,以下是我的.gitignore文件:
...
config/database.yml
.DS_Store
Run Code Online (Sandbox Code Playgroud)
后来我app_config.yml在config目录中创建了一个文件并提交了它.
现在,我意识到我不需要app_config.ymlgit存储库中的文件.我修改了我的.gitignore文件:
...
config/app_config.yml
config/database.yml
.DS_Store
Run Code Online (Sandbox Code Playgroud)
现在,当我提交时,该app_config.yml文件仍在我的仓库中.我想从我的仓库中删除该文件.我该怎么做?
与Rspec示例并行实现Resque时,我感到困惑.以下是一个类昂贵的方法.generate(self)
类SomeClass ... ChangeGenerator.generate(self)... end
实现resque后,上面的类更改为以下内容并添加了ChangeRecorderJob类.
class SomeClass
...
Resque.enqueue(ChangeRecorderJob, self.id)
...
end
class ChangeRecorderJob
@queue = :change_recorder_job
def self.perform(noti_id)
notification = Notification.find(noti_id)
ChangeGenerator.generate(notification)
end
end
Run Code Online (Sandbox Code Playgroud)
它完美地运作.但我有两个问题.
之前,我的示例规范用于测试整个堆栈的.generate(self)方法.但是现在我把它推进到Resque工作中,我如何能够将我的示例连接起来以使相同的测试变为绿色而不会孤立?或者我必须隔离测试?
最后,如果我有10个工作岗位,我是否必须使用self.perform方法创建10个单独的工作类?
以下查找器打印出来IS NULL.
User.where(:id =>nil) #=> []
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IS NULL ORDER BY created_at DESC
Run Code Online (Sandbox Code Playgroud)
但我找不到如何打印IS NOT NULL一个?
git ×2
gitignore ×2
ruby ×2
activerecord ×1
gemfile ×1
git-checkout ×1
graphite ×1
mongodb ×1
mongoid ×1
python ×1
python-2.7 ×1
resque ×1
rspec ×1
rubygems ×1