开发者

Ruby on rails undefined method `where' for #<Class:0x10377d590>

I am trying to migrate from windows 7 to mac osx . I have installed the following

  1. ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  2. 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 FROM users[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.


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.


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:

/usr/local/mysql/bin

Generally you should just have to list mysql in your Gemfile after that, and it should install conventionally with bundle 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.


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

rails server

from the console (from within the directory of the app) ?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜