Rails中STI的RESTful routes问题
POSTED AT: 2010-06-10 09:14:44 UTC |
POSTED IN: Ruby/Rails |
4 COMMENTS
不解释,你是知道STI的——single table inheritance,我们看下问题是什么
现在有两个Model:Asset和Image
class Asset < ActiveRecord::Base; end class Image < Asset; end
我们定义了这样一个RESTful routes
resources :assets
然后在我们的AssetsController里面
class AssetsController < ApplicationController def create @asset = Asset.new params[:asset] @asset.save respond_with(@asset) end def update @asset.update_attributes params[:asset] end end