[問題] 相同的instance和class method

看板Ruby作者 (甚麼時候才等到妳)時間15年前 (2010/05/10 15:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/4 (看更多)
如果有相同結構的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
文章代碼(AID): #1BvxPwCb (Ruby)
文章代碼(AID): #1BvxPwCb (Ruby)