Rails正式参数不能是实例变量吗?

Ala*_*man 1 ruby ruby-on-rails ruby-on-rails-3

我有一个rails错误,我不知道在哪里解决它.在"产品#show"上我得到了这个

SyntaxError at /products/63  formal argument cannot be an instance variable
Run Code Online (Sandbox Code Playgroud)

我评论了控制器和视图中的所有内容

def show
  # @product = Product.find(params[:id])
end
Run Code Online (Sandbox Code Playgroud)

我的错误gem指向activesupport(3.2.13)lib/active_support/dependencies.rb

  newly_defined_paths = new_constants_in(*parent_paths) do
    result = Kernel.load path     #this is the line with the error
  end
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢.

Zac*_*emp 7

当您具有无效的块参数名称时,通常会出现此错误.

例如@products.each do |@product| ...@products.each do |Product|...两者都应该@products.each do |product|.

检查您的products/show视图文件,并确保您的块参数都是没有@符号的小写单词.

这也可能是某个方法定义(def my_method(@var)...)