视图内部的部分未定义方法错误

时间:2013-11-07 19:28:39

标签: ruby-on-rails

我在显示视图中添加了部分内容,但是我收到了被调用的部分内部未定义方法的错误。我在其他地方使用部分,它工作正常。我想我需要定义一个局部变量,但我不确定哪一个

用户/ show.html.erb

<h2>Copy To Approve</h2>
<div id="basic_details" class="idea-show-columns">
<%= render :partial => "/ideas/idea_basic_show" %>
<%= render :partial => "/ideas/comments" %>
<%= render :partial => "/ideas/mockups"%>
</div>

<div id="copy_details" class="idea-show-columns">
  <%= render :partial => "/ideas/copy_show" %>
</div>

partial:ideas / idea_basic_show.html.erb

<fieldset data-model="idea-basic" class="idea-edit">
   <h2>Basic Idea Specs</h2>

  <div data-attribute="product_sku" class="edit-field">
    <%= label :sku, "Product SKU" %>
    <%= f.text_field :sku %>
  </div>

  <div data-attribute="working_name" class="edit-field">
    <%= label :working_name, "Working Name" %>
    <%= f.text_field :working_name %>
  </div>
  <div data-attribute="priority" class="edit-field">
    <%= f.label :priority, 'Priority Level' %>
    <%= f.select :priority, Idea::PRIORITIES.collect{ |level, label| [label, level]} %>
  </div>

<% if current_user.has_overlord_access? %>
      <div data-attribute="overlord_id" class="edit-field">
        <%= f.label :overlord_id, 'Sign Off' %>
        <%= f.select :overlord_id, User.overlords.collect{|o| [o.full_name, o.id]}, 
:include_blank => true %>
     </div>
 <% end %>
 <br data-clear="all" />
 <div data-attribute="working_description" class="edit-field">
   <%= label :working_description, "Working Description" %>
   <%= f.text_area :working_description %>

  </div>
    </fieldset>

我在这个部分中得到的错误具体是:

未定义的方法`sku'代表nil:NilClass

就像我说的,我认为我需要在我的部分中定义一个局部我只是不知道语法

1 个答案:

答案 0 :(得分:0)

像这样的本地语法

<%= render :partial => "/ideas/copy_show", :locals => {:f => f} %>

现在在部分页面中使用f