I am attempting to load relations via database data in the model ============================================================================ belongs_to :asset_type AssetType.asset_connection_names.each do |at| belongs_to at, :foreign_key => ''asset_id'' end def method_missing(method, *args) if(method.to_s =~ /^asset/) send asset_type.name + method.to_s.gsub(/^asset/, '''') else super(method, args) end end ==============================================================================the test =============================================================================== fixtures :contents, :htmls, :asset_types # Replace this with your real tests. def test_belongs_to_asset content = Content.find(1) assert_equal(contents(:one), content) assert_equal(asset_types(:html).name, content.asset_type.name) assert_respond_to(content, :html) assert_equal(htmls(:hello_world).headline, content.asset.headline) end ==============================================================================the weird shit ==============================================================================when running the test suite individualy it passes when runnning rake test:units AssetType.asset_connection_names.each do |at| belongs_to at, :foreign_key => ''asset_id'' end fails to execute ============================================================================= any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you can see the full app via svn checkout http://duality-cms.rubyforge.org/svn/ or svn checkout svn://rubyforge.org/var/svn/duality-cms -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5 Nov 2007, at 22:36, Keynan Pratt wrote:> > when runnning rake test:units > > AssetType.asset_connection_names.each do |at| > belongs_to at, :foreign_key => ''asset_id'' > end >what do you mean by fails to execute ? Doesn''t run at all, throws some weird error, something else?. The model is only going to be loaded once, so if you had a test which used that model but didn''t say fixtures asset_types, weirdness could quite easily happen. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> what do you mean by fails to execute ? Doesn''t run at all, throws some > weird error, something else?. > The model is only going to be loaded once, so if you had a test which > used that model but didn''t say fixtures asset_types, weirdness could > quite easily happen. > > FredThe code Doesn''t run at all. And asset_types is included in the fixtures for this test suite so it should be reloaded before the test executes should it not? Do you mean to say that the code AssetType.asset_connection_names.each do |at| belongs_to at, :foreign_key => ''asset_id'' end is executed on load and not on instantiation? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 6 Nov 2007, at 19:33, Keynan Pratt wrote:>> > > The code Doesn''t run at all. And asset_types is included in the > fixtures > for this test suite so it should be reloaded before the test executes > should it not? > > Do you mean to say that the code > > AssetType.asset_connection_names.each do |at| > belongs_to at, :foreign_key => ''asset_id'' > end >It''s executed at the point the model is loaded. I wouldn''t want to bet when exactly that is (stick a breakpoint in and find out). Fred> is executed on load and not on instantiation? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---