how does this Ruby class method get invoked?

前端 未结 2 2021
后悔当初
后悔当初 2020-12-18 10:53

In a screen cast on Exporting CSV from a rails app, Ryan Bates presented the following simple code.

I\'m trying to figure out how the class method Product::to_csv ac

2条回答
  •  一向
    一向 (楼主)
    2020-12-18 11:18

    This is just one of the things Rails does. Any class methods automatically become available as "collection" methods, meaning they are available to the relation objects. Scopes and class methods are interchangeable that way.

提交回复
热议问题