如果有相同結構的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