Hello, I''m a beginner with a question about concatenating some things. The app I''m trying to work on has the following line for building the right column in a standard 3 column header/footer layout: <% @content_for_right = render( :partial => ''shared/user_profile'', :object => @user) %> Where user_profile includes a picture of the person and some other stuff. I''ve created an additional view file, shared/_advert.rhtml If we want @content_for_right to now include both user_profile and also _advert, how would you re-write the above line to show both? Many thanks, rob b ps. I may not be using the ''view'' terminology correctly. -- 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 -~----------~----~----~----~------~----~------~--~---
any file that starts with and underline (_advert.rhtml) is actually a partial. To display another partial you simply call render(:partial => "shared/advert") again, though you may want to rethink how you''re printing it to the overall view. Instead of setting a variable to hold your render partial, maybe just print it straight to the view [view] <%= render(:partial => "my_partial") %> [/view] otherwise if you absolutely need to concat the two, I believe that partial simply returns a string so if you must you should be able to do this: [view] <% content_for_right = (render(:partial => "user_profile") + render(:partial => "advert")) %> [/view] It''s possible to do, but you may want to reconsider your approach the layout of your page. On 11/29/06, Rob Ba <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hello, > > I''m a beginner with a question about concatenating some things. The app > I''m trying to work on has the following line for building the right > column in a standard 3 column header/footer layout: > > <% @content_for_right = render( :partial => ''shared/user_profile'', > :object > => @user) %> > > Where user_profile includes a picture of the person and some other > stuff. > > I''ve created an additional view file, shared/_advert.rhtml > > If we want @content_for_right to now include both user_profile and also > _advert, how would you re-write the above line to show both? > > Many thanks, > > rob b > > ps. I may not be using the ''view'' terminology correctly. > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Mike Weber Web Developer UW-Eau Claire --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It looks like you would also be interested in the "content_for" method. Check out the api or this article on "Err the Blog": http://errtheblog.com/post/28 On 11/29/06, Mike Weber <mikep.dubya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > any file that starts with and underline (_advert.rhtml) is actually a > partial. To display another partial you simply call render(:partial => > "shared/advert") again, though you may want to rethink how you''re printing > it to the overall view. Instead of setting a variable to hold your render > partial, maybe just print it straight to the view > [view] > <%= render(:partial => "my_partial") %> > [/view] > > otherwise if you absolutely need to concat the two, I believe that partial > simply returns a string so if you must you should be able to do this: > > [view] > <% content_for_right = (render(:partial => "user_profile") + > render(:partial => "advert")) %> > [/view] > > It''s possible to do, but you may want to reconsider your approach the > layout of your page. > > On 11/29/06, Rob Ba <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > > Hello, > > > > I''m a beginner with a question about concatenating some things. The app > > I''m trying to work on has the following line for building the right > > column in a standard 3 column header/footer layout: > > > > <% @content_for_right = render( :partial => ''shared/user_profile'', > > :object > > => @user) %> > > > > Where user_profile includes a picture of the person and some other > > stuff. > > > > I''ve created an additional view file, shared/_advert.rhtml > > > > If we want @content_for_right to now include both user_profile and also > > _advert, how would you re-write the above line to show both? > > > > Many thanks, > > > > rob b > > > > ps. I may not be using the ''view'' terminology correctly. > > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---