0

我像这样渲染部分视图。

<%= render :partial => 'resources/positions', :controller => 'resources',
                         :action => 'this_is_a_test',
                         :locals => {:id_resource => 42} %>

资源控制器.rb

def this_is_a_test
    @test1 = "batman"
    render :partial => 'positions'
  end

_positions.html.erb

<%= @test1 %>

但变量@test1 为空。你有什么主意吗 ?

4

1 回答 1

1
def this_is_a_test
  render :partial => 'positions', :locals => { :test1 => "batman" }
end

并更改_position.html.erb

<%= test1 %>
于 2012-08-05T16:23:24.533 回答