开发者

Rails/Devise - NoMethodError (undefined method new_with_session' for #<Class:0x2b2a4e34>)

I've got a very strange issue, which arose quite unexpectedly during testing/bugfixing on my production environment (FreeBSD/Apache/Passenger/MySQL):

$ tail log/production.log

Started GET "/users/sign_up" for 192.168.5.7 at 2011-08-06 21:37:53 +0400
  Processing by Devise::RegistrationsController#new as
  SQL (1.5ms)  SHOW TABLES
Completed   in 15ms

NoMethodError (undefined method `new_with_session' for #<Class:0x2b2a4e34>):
  app/controllers/registrations_controller.rb:71:in `build_resource'
  app/controllers/re开发者_StackOverflow社区gistrations_controller.rb:8:in `new'

User management is organized with Devise gem. Sign in page is OK, Sign up page throws this error.

Everything went very well till I changed one of the fields (not related to Devise) in the database (changed type int -> bigint), and uploaded db/schema.rb and db/migrations/20110412205837_rename_files.rb. Then I reset the database with

$ rake db:setup RAILS_ENV='production'

, restarted the app with

$ touch tmp/restart.txt

, tried to sign up as a new user - and then saw that unhappy error page and the NoMethodError report in log file. I didn't change the devise section in models/user.rb file (OK, I did, but I also restarted the app after that and all was fine).

Here is my models/user.rb devise section:

devise :database_authenticatable, :registerable

I am sure that this is a miserable issue, maybe a mistype of something else, a very little nasty bug, but I can't imagine what it can be... I've been looking for it for two days and I don't know where else to look. Please people help!

I've already tried the following:

  • Returned to the previous version of db/schema.rb, and reset the DB;
  • Downgraded to the previous version of the whole rails app;
  • Moved app/controllers/registrations_controller.rb to app/controllers/devise and app/controllers/registrations directories;
  • Downgraded Devise gem from 1.1.7 to 1.1.2;
  • Restarted Passenger, Apache, and the whole FreeBSD;
  • looked in the /var/log/httpd.log and /var/log/httpd_error.log files;
  • recreated the database;
  • checked and recreated MySQL users and grants;
  • Bundle update;

Nothing helps...

What else can I do? Why did this problem appear?

Thanks VERY MUCH to any input in advance!


For anyone else experiencing this pain, there is a chance you were as silly as me and forgot include:

# app/models/user.b
devise :registerable

in your model.


I changed the owner of the whole app directory to www

$ chown -R www data

(didn't help at that moment though)

Then, updated previously downgraded (during the bug hunt) Devise to the latest 1.4.2 version with

$ bundle update

Then it all helped. I think (though I don't understand why) that the owner of the files should be the same owner as the owner of httpd process (check with $ ps aux | grep httpd ).

Hopefuly it will help someone

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜