Lee.Longmore-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Apr-29 04:54 UTC
Controller instance variables not visible in helper method called from rjs template
I have the following code in an rjs template that I should like to
move to a helper method associated with the controller:
if @read_access.value == "MemberEntityAccessibility"
page.insert_html :bottom, ''read_access_list'',
:partial => ''grantee'',
:collection => @read_grantees
page.show ''set_read_member_entities''
end
I created a helper method called display_grantees and placed the above
code within it.
I then called the method from within the existing rjs template using
page.display_grantees.
I get an error complaining of a nil object for @read_access (ie.
nil.value)
If I leave the code in the rjs template, it works fine. That is, I
know the instance variables @read_access etc are being initialised
correctly.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2007-Apr-29 08:54 UTC
Re: Controller instance variables not visible in helper method called from rjs template
Lee.Longmore-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> I have the following code in an rjs template that I should like to > move to a helper method associated with the controller: > > if @read_access.value == "MemberEntityAccessibility" > page.insert_html :bottom, ''read_access_list'', > :partial => ''grantee'', > :collection => @read_grantees > page.show ''set_read_member_entities'' > end > > I created a helper method called display_grantees and placed the above > code within it. > > I then called the method from within the existing rjs template using > page.display_grantees.Try calling the helper as controller.display_grantees(page)> I get an error complaining of a nil object for @read_access (ie. > nil.value)-- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---