Ruby on Rails 未定义方法“where”对于#<类 :0x10377d590>类>
我正在尝试从 windows 7 迁移到 mac osx 。 我已经安装了以下
- ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- mysql Ver 14.14 Distrib 5.1.56,用于 apple-darwin10.3.0 (i386) 使用 readline 5.1
经过一番痛苦之后,我通过以下方式安装了我的 sql gem: sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
但当我运行我的项目时仍然如此netbeans 我收到以下错误
[4;36;1m用户列 (31.5ms)[0m
[0;1m显示用户的字段
[0m
[4;35;1mSQL (1.2ms)[0m [0mSHOW 表[0m /!\ FAILSAFE /!\ 五月星期三 04 09:53:16 +0530 2011 状态:500 内部服务器错误未定义 方法“where”
谁能告诉我我做错了什么?
数据库迁移工作正常。
I am trying to migrate from windows 7 to mac osx .
I have installed the following
- ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- mysql Ver 14.14 Distrib 5.1.56, for apple-darwin10.3.0 (i386) using
readline 5.1
After a lot of pain I installed my sql gem by :
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
But still when I run my project in netbeans I get the following error
[4;36;1mUser Columns (31.5ms)[0m
[0;1mSHOW FIELDS FROMusers
[0m
[4;35;1mSQL (1.2ms)[0m [0mSHOW
TABLES[0m /!\ FAILSAFE /!\ Wed May
04 09:53:16 +0530 2011 Status: 500
Internal Server Error undefined
method `where' for
Can anyone tell me what am I doing wrong ?
The database migrations are working perfectly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您在堆栈跟踪即将告诉您错误发生位置时停止了复制堆栈跟踪。向下查看堆栈跟踪,查找应用程序中第一次提到的任何代码(而不是 gems 或供应商文件夹),它应该将您指向问题行。
You stopped copying the stack trace right at the point where it was about to tell you where the error occurs. Look down the stack trace for the first mention of any code from your app (as opposed to the gems or the vendor folder) and it should point you to the problem line.
不幸的是,您安装 MySQL gem 的时间很长,但是如果您将其加载到缺少开发标头(编译扩展所需的东西)的从头开始的计算机上,那么这可能会很复杂,并且您的路径没有包括常见的
/usr/local/mysql/bin
。您可以通过使用以下内容创建文件
/etc/paths.d/mysql
来解决此问题:通常,您只需在
Gemfile
中列出mysql
code> 之后,它应该使用bundle install
进行常规安装。至于错误,它看起来像是应用程序中更深层次的错误。当您说“在 netbeans 中运行您的项目”时,您的意思是运行单元测试吗?看起来您正在对不支持它的东西调用
where
。It's unfortunate that you've having such a time installing the MySQL gem, but this can be complicated if you're loading it on a from-scratch machine that's missing the development headers, something required to compile the extension, and your path does not include
/usr/local/mysql/bin
which is common.You can fix that by creating a file
/etc/paths.d/mysql
with the following:Generally you should just have to list
mysql
in yourGemfile
after that, and it should install conventionally withbundle install
.As for the error, it looks like something deeper in your application that's blowing a gasket. When you say "run your project in netbeans," but do you mean run unit tests? It looks like you're calling
where
on something that doesn't support it.这看起来像是一个应用程序错误。当服务器无法评估“where”方法(可能在代码中的某个位置)时,服务器将返回 500。
现代 Mac 操作系统(忘记哪个是第一个)预装了 ruby 和 Rails - 不确定这是否与您的设置有关。
运行时会发生什么?
当您从控制台(从应用程序的目录内)
This looks like an application error. The server is bailing with a 500 when it fails to evaluate the method 'where', somewhere likely in your code.
Modern Mac operating systems (forget which was the first) come with ruby and rails pre-installed - not sure if this is related to your setup.
What happens when you run
from the console (from within the directory of the app) ?
where
是用于条件的 ActiveRecord 3 AREL 类方法。首先,你是否安装了XCode?这是安装任何本机 gem 的先决条件。您可以从苹果网站下载 XCode 3 或从应用商店购买 XCode 4。
需要更多的堆栈跟踪。
理想情况下,一旦安装了 XCode,您应该查看 https://rvm.io - 这是首选方式用于管理 Unixy 系统上的 rubies。
where
is a ActiveRecord 3 AREL class method used for conditions.First things first, do you have XCode installed? thats a prerequisite to installing any native gems. You can download XCode 3 from the apple site or buy XCode 4 from the app store.
More of the stack trace is required.
Ideally though, once you have installed XCode, you should take a look at https://rvm.io - it's the preferred way for managing rubies on Unixy systems.
谢谢大家..我终于发现错误出在 authlogic gem 上
我已经安装了3.0.2
并且该应用程序需要旧版本 2.x
Thanks guys.. I finally found the error was with the authlogic gem
I had installed 3.0.2
and the application requires an older version 2.x