Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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 RubyonRails:未定义的方法'user';对于#<;ActiveRecord::Relation::ActiveRecord\u Relation\u用户:0x445148>;_Ruby On Rails_Ruby_Scaffold - Fatal编程技术网

Ruby on rails RubyonRails:未定义的方法'user';对于#<;ActiveRecord::Relation::ActiveRecord\u Relation\u用户:0x445148>;

Ruby on rails RubyonRails:未定义的方法'user';对于#<;ActiveRecord::Relation::ActiveRecord\u Relation\u用户:0x445148>;,ruby-on-rails,ruby,scaffold,Ruby On Rails,Ruby,Scaffold,代码如下。User是我数据库中的名称,但它说它是一个未定义的方法,而不应该是。它只是我数据库中的一个字符串值。我已经看过了所有其他关于这个错误的帖子,但是他们的解决方案对我不起作用。(顺便说一句,我使用了脚手架,所以我不知道这是否会影响任何事情) 这一行: the_user = self.where(user: user, password:password) 应该是: the_user = self.where(user: user, password:password).first 没有

代码如下。User是我数据库中的名称,但它说它是一个未定义的方法,而不应该是。它只是我数据库中的一个字符串值。我已经看过了所有其他关于这个错误的帖子,但是他们的解决方案对我不起作用。(顺便说一句,我使用了脚手架,所以我不知道这是否会影响任何事情)

这一行:

the_user = self.where(user: user, password:password)
应该是:

the_user = self.where(user: user, password:password).first
没有
.first
您得到的是一个关系对象,它可以用来进一步链接
.where
子句(或类似的方法)。必须首先使用
。或类似于
的方法从数据库中实际获取记录。

此行:

the_user = self.where(user: user, password:password)
应该是:

the_user = self.where(user: user, password:password).first
没有
.first
您得到的是一个关系对象,它可以用来进一步链接
.where
子句(或类似的方法)。必须首先使用
。或类似于
的方法从数据库中实际获取记录。

此行:

the_user = self.where(user: user, password:password)
应该是:

the_user = self.where(user: user, password:password).first
没有
.first
您得到的是一个关系对象,它可以用来进一步链接
.where
子句(或类似的方法)。必须首先使用
。或类似于
的方法从数据库中实际获取记录。

此行:

the_user = self.where(user: user, password:password)
应该是:

the_user = self.where(user: user, password:password).first
没有
.first
您得到的是一个关系对象,它可以用来进一步链接
.where
子句(或类似的方法)。您必须首先使用
.first
或类似于
的方法来从数据库中实际获取记录