在我的routes.rb中我有以下内容:
resources :message_threads
Run Code Online (Sandbox Code Playgroud)
我打电话的时候:
message_threads_path(1)
Run Code Online (Sandbox Code Playgroud)
我明白了:
/message_threads.1
Run Code Online (Sandbox Code Playgroud)
为什么是这样?我的其他资源运作正常.我没有正确地复数这个或什么?
我开发的一个常见场景是代码库将有几个配置文件需要特定于机器的设置.这些文件将被检入Git,其他开发人员将不小心将它们重新检入并打破其他人的配置.
一个简单的解决方案就是不将它们检入Git,甚至为它们另外添加.gitignore条目.但是,我发现在文件中有一些合理的默认值更加优雅,开发人员可以根据自己的需要进行修改.
有没有一种优雅的方式让Git很好地使用这些文件?我希望能够修改特定于机器的配置文件,然后能够在不检查该文件的情况下运行"git commit -a".
在Xcode 3.x中,我可以执行编辑>排序>按名称.我在新版本的Xcode中找不到此功能.有谁知道怎么做到这一点?
我试图使用ThreadPoolExecutor执行许多任务.以下是一个假设的例子:
def workQueue = new ArrayBlockingQueue<Runnable>(3, false)
def threadPoolExecutor = new ThreadPoolExecutor(3, 3, 1L, TimeUnit.HOURS, workQueue)
for(int i = 0; i < 100000; i++)
threadPoolExecutor.execute(runnable)
Run Code Online (Sandbox Code Playgroud)
问题是我很快得到了java.util.concurrent.RejectedExecutionException,因为任务数量超过了工作队列的大小.但是,我正在寻找的所需行为是让主线程阻塞,直到队列中有空间.完成此任务的最佳方法是什么?
我通过一系列设置调用设置了很多属性,例如
this.set('prop1', value1);
this.set('prop2', value2);
.......
Run Code Online (Sandbox Code Playgroud)
有没有办法在一次调用中执行此操作(类似于创建对象时)?例如
this.setMultiple({prop1: value1, prop2: value2});
Run Code Online (Sandbox Code Playgroud)
我仍然没有完全理解Ember的继承模型.也许是沿袭的reopen?
以前,我一直在使用ssl_requirement来对我们通过ssl提供服务的页面进行细粒度控制,并通过纯http提供服务.
根据ssl_requirement自己的wiki,它已被rails 3.1的Force SSL 取代.然而,情况似乎并非如此.强制SSL似乎没有暴露出相反方向的选项,没有办法强制页面通过常规http发送.
什么是正确的Rails 3.1方式强制页面以纯http显示?Force SSL真的取代了ssl_requirement吗?
在我们当前的rails应用程序中,我们遵循某些模式来包含脚本和样式表等资产.
例如,一个这样的模式是(布局内的代码):
= stylesheet_link_tag controller.controller_name
Run Code Online (Sandbox Code Playgroud)
这里的问题是并非所有控制器都有相关的样式表.检查资产是否存在的最佳方法是什么?具体来说,我知道由于缓存破坏资产名称,这里有一些技巧.
我有这样的关系:
Parent
has_many :children
Child
belongs_to :parent
Run Code Online (Sandbox Code Playgroud)
我想要做的是删除父母,如果没有更多的孩子.所以要做到这一点我有:
Child
before_destroy :destroy_orphaned_parent
def destroy_orphaned_parent
parent.children.each do |c|
return if c != self
end
parent.destroy
end
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我也想将父级的删除级联到子级.我通常会这样做:
Parent
has_many :children, :dependent => :destroy
Run Code Online (Sandbox Code Playgroud)
这会导致WebRick服务器在测试时崩溃.我假设这是由于最后一个孩子的无限循环删除父母删除孩子等.
我开始认为有更好的方法可以做到这一点?有人有主意吗?有没有办法阻止这种递归?
这似乎是一个愚蠢的问题,但我无法在任何地方找到答案.我正在使用Rails 3.1和Test :: Unit.
当测试失败时,我只看到堆栈的顶部,例如:
ERROR creating a message sends emails (1.35s)
NoMethodError: undefined method `project' for nil:NilClass
/Users/ghempton/.rvm/gems/ruby-1.9.2-p180@gt/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
Run Code Online (Sandbox Code Playgroud)
如何查看完整堆栈跟踪?
我试图将Ember.js与jQuery UI的可拖动功能结合使用,但我遇到了问题.具体来说,当使用克隆助手时,我无法删除元素,一切都非常滞后.如果我不使用克隆助手,一切都按预期工作.
我怀疑这与jQuery UI克隆html有关,包括所有的变形脚本标签(用于绑定).
我拖动它时不需要更新元素.有没有办法剥离绑定标签与ember?
作为参考,这里是视图逻辑:
didInsertElement: ->
@_super()
@$().draggable
cursor: 'hand'
helper: 'clone'
opacity: 0.75
scope: @draggableScope
@$().droppable
activeClass: 'dropActive'
hoverClass: 'dropHover'
drop: @createMatch
scope: @droppableScope
Run Code Online (Sandbox Code Playgroud)
我的第一个想法是尝试使用a beginPropertyChanges并endPropertyChanges在拖动期间防止意外行为.这似乎不起作用,也不是理想的,因为我希望其他绑定更新.以下是我尝试过的修改后的代码:
didInsertElement: ->
@_super()
@$().draggable
cursor: 'hand'
helper: 'clone'
opacity: 0.75
scope: @draggableScope
start: ->
Ember.beginPropertyChanges()
stop: ->
Ember.endPropertyChanges()
@$().droppable
activeClass: 'dropActive'
hoverClass: 'dropHover'
drop: @createMatch
scope: @droppableScope
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
ember.js ×2
activerecord ×1
concurrency ×1
executor ×1
git ×1
java ×1
jquery-ui ×1
rack ×1
ruby ×1
ssl ×1
unit-testing ×1
xcode ×1
xcode4 ×1