Local variable not passed to private template by render?

It seems I can not pass the variable to my partial template in rails (2.3.5). My code is as follows:

In the main view, the .html.erb file:

<% f.fields_for :payments do |payment_form| %> <%= render 'payment', {:f => payment_form, :t => "test" } %> <% end %> 

and in the _payment.html.erb file:

 <%= t %> 

throws the wrong number of arguments (0 for 1) error. The payment_form object is partially passed as f without any problems. I tried several variations of this syntax (for example :locals => {:f => payment_form, :t => "test" } without success. I suppose I'm doing something fairly simple, but just can't see it.

+4
source share
3 answers

Probably because t () is a helper method of the reserved representation used for I18n. Just rename it to something more descriptive.

+2
source

Try

 render :partial => 'payment', :locals => {:t => 'test'} 
+1
source

Have you tried <%= render 'payment', :f => payment_form %>

I'm not sure why: t, but the rails obviously say that you should only pass one extra parameter with the wrong number of arguments (0 for 1).

+1
source

Source: https://habr.com/ru/post/1307227/


All Articles