Can anyone point me towards the documentation regarding variable scope for rendering nested partials? I''ve got a controller view [list.rhtml] that invokes a parial render using an array of objects [render(:partial => ''shared/track_in_table'', :collection => @tracks)]. I want the track_in_table view, in turn, to invoke another partial render [render(:partial => ''shared/track_rating'', @object => track_in_table)] using the same track that is being passed as an object in the track_in_table view. However, a "NoMethodError" exception (undefined method ''blah'' for nil:NilClass) is being thrown from _track_rating.rhtml, which tells me that the track object isn''t being passed on properly to the nested partial view. Any thoughts? I''ve searched the list archives and Googled it, but I can''t seem to find anything... Thanks. dave
I have the same problem...no solution until now 2005/8/23, dave miller <davidfmiller-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Can anyone point me towards the documentation regarding variable scope > for rendering nested partials? I''ve got a controller view [list.rhtml] > that invokes a parial render using an array of objects > [render(:partial => ''shared/track_in_table'', :collection => @tracks)]. > I want the track_in_table view, in turn, to invoke another partial > render [render(:partial => ''shared/track_rating'', @object => > track_in_table)] using the same track that is being passed as an > object in the track_in_table view. However, a "NoMethodError" > exception (undefined method ''blah'' for nil:NilClass) is being thrown > from _track_rating.rhtml, which tells me that the track object isn''t > being passed on properly to the nested partial view. > > Any thoughts? I''ve searched the list archives and Googled it, but I > can''t seem to find anything... Thanks. > > dave > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Giovanni Degani tiefox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org ICQ 965609 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I haven''t tried this so I could be totally off, but wouldn''t something like: render(:partial => ''shared/track_rating'', :locals => {:track => trackObject}) I''m not sure what you''re trying to pass to the shared/track_rating partial so the above :track => trackObject is just an example. -andy -- Andrew Stone _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I''m doing this exacltly in the way Andrew suggested and it works perfectly.> I haven''t tried this so I could be totally off, but wouldn''t > something like: > > render(:partial => ''shared/track_rating'', :locals => {:track => > trackObject}) > > I''m not sure what you''re trying to pass to the shared/track_rating > partial so the above :track => trackObject is just an example. > > -andy > -- > Andrew Stone > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I''m doing this exactly in the way Andrew suggested for an helper and it works perfectly. def appear(obj, loc1, loc2) render(:partial => ''shared/appear'', :object => obj, :locals => { :loc1 => loc1, :loc2 => loc2, } ) end Ettore Berardi> I haven''t tried this so I could be totally off, but wouldn''t > something like: > > render(:partial => ''shared/track_rating'', :locals => {:track => > trackObject}) > > I''m not sure what you''re trying to pass to the shared/track_rating > partial so the above :track => trackObject is just an example. > > -andy > -- > Andrew Stone > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >