ok i''m having problems moving a piece of code into a partial I have a line in a view: <%= image_tag( createturing ) %> moving to a partial _createturing.rhtml and changing the view to: <div id="turing"><%= render(:partial => "createturing") %></div> gives errors: ActionView::TemplateError (can''t convert nil into String) on line #1 of accounts/_createturing.rhtml: 1: <%= image_tag( createturing ) %> what changes do i need to make when i move it into the partial? btw: the function createturing is in a helper if that makes a differance! --~--~---------~--~----~------------~-------~--~----~ 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 27 Dec 2007, at 00:54, spokra wrote:> > ok i''m having problems moving a piece of code into a partial > > I have a line in a view: > > <%= image_tag( createturing ) %> > > moving to a partial _createturing.rhtml and changing the view to: > > <div id="turing"><%= render(:partial => "createturing") %></div> > > gives errors: > > ActionView::TemplateError (can''t convert nil into String) on line #1 > of accounts/_createturing.rhtml: > 1: <%= image_tag( createturing ) %> >By default when looking at the partial createturing rails will set the local variable createturing to the value of @createturing which would seem to be nil. You however don''t want to use the local variable createturing but the method of the same name. You can force a method call by saying createturing() instead of createturing Fred> > what changes do i need to make when i move it into the partial? > > btw: the function createturing is in a helper if that makes a > differance! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
spokra wrote:> ok i''m having problems moving a piece of code into a partial > I have a line in a view: > <%= image_tag( createturing ) %> > moving to a partial _createturing.rhtml and changing the view to: > <div id="turing"><%= render(:partial => "createturing") %></div> > gives errors: > ActionView::TemplateError (can''t convert nil into String) on line #1 > of accounts/_createturing.rhtml: > 1: <%= image_tag( createturing ) %> > what changes do i need to make when i move it into the partial? > > btw: the function createturing is in a helper if that makes a > differance!i think the render line should be: <%= render :partial => ''createturing'' %> without the brackets~ -- 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 -~----------~----~----~----~------~----~------~--~---
It''s because you''re trying to pass a local variable to a partial, and that won''t work. Change it to an instance variable or specify :locals => { :variable_name => variable_name } in your partial. -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I knew that it had to be something easy i was missing!! and it works correctly now!! Thank you!! now to implement my refresh of the div... On Dec 26, 5:26 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 27 Dec 2007, at 00:54, spokra wrote: > > > > > > > > > ok i''m having problems moving a piece of code into a partial > > > I have a line in a view: > > > <%= image_tag( createturing ) %> > > > moving to a partial _createturing.rhtml and changing the view to: > > > <div id="turing"><%= render(:partial => "createturing") %></div> > > > gives errors: > > > ActionView::TemplateError (can''t convert nil into String) on line #1 > > of accounts/_createturing.rhtml: > > 1: <%= image_tag( createturing ) %> > > By default when looking at the partial createturing rails will set the > local variable createturing to the value of @createturing which would > seem to be nil. > You however don''t want to use the local variable createturing but the > method of the same name. You can force a method call by saying > createturing() instead of createturing > > Fred > > > > > > > what changes do i need to make when i move it into the partial? > > > btw: the function createturing is in a helper if that makes a > > differance!- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---