Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 品鉴中的命名错误_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 品鉴中的命名错误

Ruby on rails 品鉴中的命名错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,我正在创建一个博客网站,我正在努力添加评论部分。我安装了commontator gem,并按照以下步骤操作。我在我的用户模型中使用了acts_as_commontator。在我的PIN模型中充当\u公共表。在我的别针秀上 我有一个命名者。我不明白为什么当我的模型中有方法时,它不理解我的方法调用 我的Pin show.html.erb <div class="row"> <div class="col-md-offset-2 col-md-8"> <div

我正在创建一个博客网站,我正在努力添加评论部分。我安装了commontator gem,并按照以下步骤操作。我在我的用户模型中使用了acts_as_commontator。在我的PIN模型中充当\u公共表。在我的别针秀上

我有一个命名者。我不明白为什么当我的模型中有方法时,它不理解我的方法调用

我的Pin show.html.erb

<div class="row">
  <div class="col-md-offset-2 col-md-8">
   <div class="panel panel-default">
    <div class="panel-heading center">
     <%= image_tag @pin.image.url(:medium) %>
    </div>
     <div class="panel-body">
      <p><%= @pin.description %></p>
      <p><strong><%= @pin.user.name if @pin.user %></strong></p>

      <% if @pin.user == current_user %>
      <%= link_to 'Edit', edit_pin_path(@pin) %>
      <% end %>
     </div>
    </div>
    <%= commontator_thread(@commontable) %>
  </div>
 </div>

</div>
我的模型是Pin.erb

class Pin < ActiveRecord::Base
belongs_to :user
has_attached_file :image, :styles => { :medium => "300x300>", :thumb =>          "100x100>" }
validates_attachment_content_type :image, :content_type => ["image/jpg",    "image/jpeg", "image/png", "image/gif"]
validates :image, presence: true
acts_as_commontable
end
My Models User.erb

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
 devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

 has_many :pins

 validates :name, presence: true
acts_as_commontator
end

最常见的问题是@commontable变量为nil,然后得到NoMethodError,它希望得到一个:id


检查@commontable是否为非零,并尝试使用@pin更改@commontable,这看起来很好,因为他不会在编辑路径上抛出任何错误

包含stacktrace的相关部分以及其中所示区域周围的代码会很有帮助……您是否在控制器文件中添加了commontator_thread_showcommontable?不要发布代码图片的链接。键入它们。不要偷懒。不要期望其他人做你的工作。我曾尝试将CommonStator\u thread\u showcommontable添加到我的应用程序控制器或我的PIN控制器中,结果出现路由错误扫描你尝试使用而不是CommonStator\u thread\u showcommontable?如果这不起作用,请尝试参考以下内容: