Hi all, I''m on rails 12.1 and I have tried to pass certain variables into a partial. However, it doesn''t seem to work, eg. <%= render_partial ''partial'', :errors => @flash[''errors''], :actn => ''someAction'' %> However, if I do this <% @actn = ''someAction ''%> <% @errors = @flash[''errors'']%> <%= render_partial ''partial'', :errors => @errors, :actn => @actn %> It works. Is this a bug? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
How you are accessing the variable in the partial template? It is treated as a local variable, so you don''t need @ in front of it. If the _partial.rhtml template contains the following: <%= actn %> You will see a simple page with the text someAction displayed. This is just a guess as to what your problem is, based on what you have said. Partials are working great for me. My experience is also that you don''t need to pass instance variables from the controller into partials, they have access to them already, unless you want to change the name by which they are accessed. I hope this helps. Steven Chan wrote:> Hi all, > > I''m on rails 12.1 and I have tried to pass certain variables into a > partial. However, it doesn''t seem to work, eg. > > <%= render_partial ''partial'', :errors => @flash[''errors''], :actn => > ''someAction'' %> > > However, if I do this > > <% @actn = ''someAction ''%> > <% @errors = @flash[''errors'']%> > <%= render_partial ''partial'', :errors => @errors, :actn => @actn %> > > It works. > > Is this a bug? > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks Matthew I guess I didn''t get the intracacies of partials :) On 5/10/05, Matthew Thill <mithill-sK6dKysfGH7D0D/r9Z6QQA@public.gmane.org> wrote:> > How you are accessing the variable in the partial template? It is > treated as a local variable, so you don''t need @ in front of it. If the > _partial.rhtml template contains the following: > > <%= actn %> > > You will see a simple page with the text someAction displayed. > > This is just a guess as to what your problem is, based on what you have > said. Partials are working great for me. My experience is also that you > don''t need to pass instance variables from the controller into partials, > they have access to them already, unless you want to change the name by > which they are accessed. > > I hope this helps. > > Steven Chan wrote: > > Hi all, > > > > I''m on rails 12.1 and I have tried to pass certain variables into a > > partial. However, it doesn''t seem to work, eg. > > > > <%= render_partial ''partial'', :errors => @flash[''errors''], :actn => > > ''someAction'' %> > > > > However, if I do this > > > > <% @actn = ''someAction ''%> > > <% @errors = @flash[''errors'']%> > > <%= render_partial ''partial'', :errors => @errors, :actn => @actn %> > > > > It works. > > > > Is this a bug? > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails