English 中文(简体)
铁路反向范围
原标题:Rails reverse scope

 scope :delivered, where(:status => Status::DELIVERED)
 SELECT "orders".* FROM "orders" WHERE "orders"."status" IN ( Pending ,  Partially Prepared )

现在我想增加新的范围,以便除已交付的命令外,都能得到所有。

 scope :not_delivered, where(:status != Status::DELIVERED)
 SELECT "orders".* FROM "orders" WHERE ( t )

如何扭转范围?

问题回答

你们必须使用一种扼杀性的条件。 cop :not_delivered, where ( status NOT ? , Status:DELIVERED)

Not confident about the syntax, I don t do SQL often. But you should get the idea.





相关问题
Scope with a self-invoking function in Javascript

Take below code iterates over 6 input buttons and attaches an onclick event to every button that alerts the index number of the respective iteration: for (var i = 1; i < 6; ++i) { var but = ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

preventing data from being freed when vector goes out of scope

Is there a way to transfer ownership of the data contained in a std::vector (pointed to by, say T*data) into another construct, preventing having "data" become a dangling pointer after the vector goes ...

定型语言是否具有范围概念?

定型语言是否具有范围概念? 在我看来,如果职能参数被放在职能执行之前的位置上,这些参数就会以不正统的方式出现。

"Global" variable scope in PHP

I have a section of code like the following: ---- file.php ---- require_once("mylib.php"); function($a,$b) { $r = $_GLOBALS[ someGlobal ]; echo $r; } ---- mylib.php ---- $_GLOBALS[ ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

热门标签