2017-04-16 47 views
-3

我試圖將註釋添加到我的產品,當我提出我的意見,我得到這個錯誤在產品錯號碼的在軌產品評論參數

」引發ArgumentError#顯示

顯示C:/網站/project/app/views/comments/_comment.html.erb其中線路#3提出:

錯誤的參數數目(0給出,預期1..2)」

MY PRODUCT/SHOW.HTML。 ERB

<body style="background-image:url('/images/Linux Wallpaper.jpg');"> 

<div class="panel panel-default panel-list" style="width:70%;margin:20px auto;background-color: rgba(255,255,255,0.1);"> 
    <div class="panel-heading" style="background-color:rgba(126, 232, 173, 0.78);"> 
     <h3 class="panel-title" style="font-family:lucida;display:bold;"> 
     <% if @product.user == current_user %> 
      <p style="float: right;"><%= link_to 'Edit', edit_product_path(@product), :style=>"background-color:rgb(10, 245, 61);padding: 10px 10px 10px 10px;border-radius: 6px; border:1px solid rgba(255,255,255,0.9);" %> </p> 
<%end%> 
      <p style="float: left;"><%= link_to 'Back', products_path, :style=>"background-color:rgb(10, 245, 61);padding: 10px 10px 10px 10px;border-radius: 6px; border:1px solid rgba(255,255,255,0.9);" %><p> 
      <center>YOUR PRODUCT : <%[email protected]%></center> 
     </h3> 
    </div> 
    <div class="panel-body" style="background-color:rgba(255,255,255,0.1);"> 

    <div class="row"> 
     <div class="col-lg-9 col-md-4" style="padding-left:30px;"> 
      <%= image_tag(@product.img_url.url(:large),:style => "height:400px;width:800px;border-radius: 4px; border:1px solid rgba(255,255,255,0.9);") %> 
     </div> 
     <div class="col-lg-2 col-md-2"> 
       <strong style="color:yellow;font-size:2em;font-weight:bolder;">Name:</strong><br> 
      <div style="color:lightgreen;font-size:2em;"> 
      <%= @product.title%> 
       </div> 
     </div> 
      <div class="col-lg-3 col-md-3"> 
       <strong style="color:yellow;font-size:2em;font-weight:bolder;">File Type:</strong><br> 
      <div style="color:lightgreen;font-size:2em;"> 
      <%= @product.filetype%> 
       </div> 
     </div> 
<div style="float:right;padding-right:10%;"> 
<div class="col-lg-2 col-md-2"> 
    <strong style="color:yellow;font-size:2em;font-weight:bolder;">Price:</strong><br> 
     <div style="color:lightgreen;font-size:2em;"> 
    $<%= @product.price %> 
     </div> 
     </div> 
    </div> 
    <div style="float:right;padding-right:10%;"> 
<div> 
    <strong style="color:yellow;font-size:2em;font-weight:bolder;">Tags:</strong><br> 
     <div style="color:lightgreen;font-size:2em;"> 
    $<%= @product.all_tags %> 
     </div> 
     </div> 
<div> 
<h2><%= @product.comments.count %> COMMENTS</h2> 
<p><%= render @product.comments %></p> 
<h3> ADD A COMMENT </h3> 
<p><%= render 'comments/form' %></p> 
</div> 
    </div> 
    </div> 
</div> 
</div> 

MY COMMENTS_CONTROLLER

class CommentsController < ApplicationController 
    def create 
     @product=Product.find(params[:product_id]) 
     @[email protected](params[:comment].permit(:body)) 
     redirect_to product_path(@product) 
    end 
end 

_COMMENT.HTML.ERB

<p><%= current_user.name %></p> 
<p><%= comment.body %></p> 
<p><%= time_ago_in_words.(comment.created_at)%></p> 

<p><%= link_to 'Delete',[comment.product,coment], method: :delete, data: { confirm: 'Are you sure?' } %> 
</p> 
+0

錯誤time_ago_in_words後刪除多餘的點說'引發ArgumentError在產品展示# '有'show'行動?你可以發佈嗎? –

+0

不是_views_,動作_code_。 –

+0

明顯在'Products'控制器中。 –

回答

0

從該行

= time_ago_in_words(comment.created_at)