ruby on rails named scope implementation

后端 未结 3 1601
小鲜肉
小鲜肉 2021-02-06 18:34

From the book Agile Web Development With Rails

class Order < ActiveRecord::Base
   named_scope :last_n_days, lambda { |days| {:conditions =>
      [\'updat         


        
3条回答
  •  心在旅途
    2021-02-06 19:03

    Very cool. I was thinking of doing something like this in Javascript but Javascript behaves rather weird.

    The statement:

    var x = SomeObject;
    

    does not call SomeObject's toString() function. But the statement:

    var x;
    x = SomeObject;
    

    correctly calls the toString() function as expected.

    This prevents Javascript from doing cool stuff with chaining. =(

提交回复
热议问题