作者bypang (甚麽时候才等到你)
看板Ruby
标题[问题] 相同的instance和class method
时间Mon May 10 15:32:07 2010
如果有相同结构的instance和class method,要如何做才能dry呢?
class Product < ActiveRecord::Base
def price
...
end
def self.price
...
end
end
class ProductsController < ApplicationController
# use in ajax call
def calculate
price = Product.price
end
end
谢谢各位大大
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.100.110.131