named_scope :incomplete?, lambda { |user_id, todo_id|
{ :select => 1, :conditions =>
[ "#{user_id} not in (select user_todos.user_id from user_todos) and
#{todo_id} not in (select user_todos.todo_id from user_todos)" ]
}
}
Run Code Online (Sandbox Code Playgroud)
我得到一个零结果.我希望它返回真实.我要做什么!?
还有,有更好的方法来写这个吗?
我没有看到此代码在哪里创建此NoMethodFound错误,并且非常想要任何有用的建议.
这是错误消息:
NoMethodError in UploadsController#create
Run Code Online (Sandbox Code Playgroud)
我的模型的相关部分如下所示:
named_scope :by_name, lambda { |marker_name|
{:conditions => ["marker_name = ?", marker_name]}}
def self.parse_file(file)
FasterCSV.foreach(file.path,:headers=>"first_row", :col_sep=>"\t") do |row|
if $header_row == 1
$markers = {} # define global hash for marker id lookup
$markers_arry = [] # define global array for marker names
get_markers(row)
$header_row = 0
# done with header row; loop back to beginning for first row of actual data
next
end
...
def self.get_markers(row)
offset = 8 # this was determine by …Run Code Online (Sandbox Code Playgroud) 我的模型中有以下命名范围
class User
scope :single_action, where("parent_id = ?", nil)
end
Run Code Online (Sandbox Code Playgroud)
尽管存在带有nil值的parent_id的记录,但它们似乎不可用.
ruby-1.9.2-p0 > User.select("name")
=> [#<User parent_id: nil, name: "John">, #<Task parent_id: 1, name: "Felix">, #<Task parent_id: nil, name: "John Felix">]
Run Code Online (Sandbox Code Playgroud)
我尝试使用活动记录查询来执行相同操作,但它也返回空结果集
ruby-1.9.2-p0 > User.where("parent_id = ?",nil)
=> []
Run Code Online (Sandbox Code Playgroud)
我已经定义了一些似乎工作正常的其他范围.我的Rails版本是3.0.7,Ruby版本是Ruby 1.9.2你可以帮我解决这个问题.
谢谢 :)
鉴于以下内容:
namespace Foo{
class Bar{
static const auto PRIVATE = 0;
const int private_ = 1;
void ptivateFunc() { cout << 2; }
public:
static const auto PUBLIC = 3;
const int public_ = 4;
void publicFunc() { cout << 5; }
};
}
Run Code Online (Sandbox Code Playgroud)
该声明using Foo::Bar;编译......但我不确定它是什么让我访问.任何人都可以解释一下这个陈述的重点是什么以及它能让我获得什么,Bar而不仅仅是做一个using namespace Bar?