我有一个rails错误,我不知道在哪里可以解决它。在“产品秀”上我明白了

SyntaxError at /products/63  formal argument cannot be an instance variable

我评论了控制器和视图之外的所有内容
def show
  # @product = Product.find(params[:id])
end

我的错误gem指向active support(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

有什么想法吗谢谢。

最佳答案

当块参数名无效时,通常会出现此错误。
例如@products.each do |@product| ...@products.each do |Product|...都应该
小于cc>。
检查@products.each do |product|视图文件,并确保块参数都是不带products/show符号的小写字。
这也有可能在某个地方的方法定义中(@

关于ruby-on-rails - Rails形式参数不能是实例变量吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23092993/

10-14 17:08
查看更多