Ruby on rails undefined变量

Tul*_*ler 0 ruby ruby-on-rails

我正在编写一个新的应用程序,并使用一个旧的应用程序作为如何做我正在创建新页面和使用form_for的参考

<% form_for(store) do |f| %>

<% end %>


def new
  @store = Store.new
end
Run Code Online (Sandbox Code Playgroud)

上面是我的控制器,就像我在上一个应用程序中所做的那样,并且得到了这个错误.我收到这个令我困惑的错误,因为它适用于我制作的其他应用程序.

undefined local variable or method `store' for #<#<Class:0x007fb26b3634c0>:0x007fb26a427ce0>
Did you mean?  @store
Run Code Online (Sandbox Code Playgroud)

我必须在概念上遗漏一些东西.

小智 5

你创建了变量@store,这就是为什么ruby不知道是什么store

<% form_for(@store) do |f| %>
Run Code Online (Sandbox Code Playgroud)

您应该阅读错误消息

undefined局部变量或方法`store'...你的意思是?@商店