Hi all! I''ve been using an instance of my model to do "query by example".. Basically I fill in a new instance of the model and then later interrogate it to generate my conditions for find( :all ).. Where things get ugly is that I just moved several properties into a joined table, but I''d like to keep the ability to set those attributes in the original model.. (hence the need for "virtual attributes").. Does anyone know any way of implementing this? All my attempts at hacking the attributes hash have ended in tears.. Worse case scenario; I manually maintain another model that is purely virtual .. But if anyone has any bright ideas I''d be really appreciative! Thanks!
I should clarify: I know I can make the entire model transient using the technique documented here: http://wiki.rubyonrails.com/rails/pages/ HowToUseValidationsWithoutExtendingActiveRecord I want to make a couple attributes of the model transient.. On 5-Oct-05, at 5:05 PM, Luke Galea wrote:> Hi all! > > I''ve been using an instance of my model to do "query by example".. > Basically I fill in a new instance of the model and then later > interrogate it to generate my conditions for find( :all ).. > > Where things get ugly is that I just moved several properties into > a joined table, but I''d like to keep the ability to set those > attributes in the original model.. (hence the need for "virtual > attributes").. > > Does anyone know any way of implementing this? All my attempts at > hacking the attributes hash have ended in tears.. > > Worse case scenario; I manually maintain another model that is > purely virtual .. But if anyone has any bright ideas I''d be really > appreciative! Thanks! > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Is there any way to dynamically add properties to the attributes list? I guess this is similiar to mocking activerecord.. but that technique doesn''t seem to work either :( On 5-Oct-05, at 5:24 PM, Luke Galea wrote:> I should clarify: I know I can make the entire model transient > using the technique documented here: > http://wiki.rubyonrails.com/rails/pages/ > HowToUseValidationsWithoutExtendingActiveRecord > > I want to make a couple attributes of the model transient.. > > On 5-Oct-05, at 5:05 PM, Luke Galea wrote: > > >> Hi all! >> >> I''ve been using an instance of my model to do "query by example".. >> Basically I fill in a new instance of the model and then later >> interrogate it to generate my conditions for find( :all ).. >> >> Where things get ugly is that I just moved several properties into >> a joined table, but I''d like to keep the ability to set those >> attributes in the original model.. (hence the need for "virtual >> attributes").. >> >> Does anyone know any way of implementing this? All my attempts at >> hacking the attributes hash have ended in tears.. >> >> Worse case scenario; I manually maintain another model that is >> purely virtual .. But if anyone has any bright ideas I''d be really >> appreciative! Thanks! >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >