我像这样渲染视图。
<%= render :partial => 'resources/positions', :controller => 'resources',
:action => 'this_is_a_test',
:locals => {:id_resource => 42} %>
resources_controller.rb
def this_is_a_test
@test1 = "batman"
render :partial => 'positions'
end
_positions.html.erb
<%= @test1 %>
但变量@ test1为空。你有什么主意吗 ?
答案 0 :(得分:1)
def this_is_a_test
render :partial => 'positions', :locals => { :test1 => "batman" }
end
并将_position.html.erb
更改为
<%= test1 %>