Passing @object into a rails partial render

前端 未结 5 869
后悔当初
后悔当初 2020-12-31 01:41

I have a partial:

\'profiles/_show.html.erb\'

that contains code like

<%= @profile.fullname %>

I\'m trying to render

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 02:05

    For Rails 3+, the answer to your actual question is:

    <%= render 'profiles/show', :@profile => blah %>
    

    Your partial will now see @profile locally.

    I'm not saying this is a good approach. I'm honestly not sure if this is ugly or not. But it works.

提交回复
热议问题