Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

paperclip - Rails STI conditional sub-classing from base class -


i'm developing project have entity may have 2 kinds of assets: pictures , videos, basically.

since want assets on same table , single upload form either pictures or videos, i'm using single table inheritance having both picture , video descending asset class. also, i'll running different validations/callbacks depending on whether video or picture.

i'm using paperclip deal upload process, , idea when uploading file , creating asset it, application instantiate correct subclass (picture or video) depending on mime-type of uploaded file.

this sketch of classes:

class project < activerecord::base   has_many :assets   accepts_nested_attributes_for :assets end  class asset < activerecord::base   belongs_to :project   has_uploaded_file :content, ... end  class picture < asset   validate :image_size   ... end  class video < asset   after_save :convert_format   ... end 

my idea implement before_save callback on asset class , try instantiate correct class there, i'm not sure how or if it's idea.

any idea this?

while should favor fat models , skinny controllers, me seems better placed in controller. primary rationale doing in asset model coupling base type subtypes, doesn't feel right me (although see apis time).


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -