设计中的设计 - NoMethodError #new controller

时间:2011-06-28 08:49:58

标签: ruby-on-rails devise nomethoderror

我的开发机器上的一切正常(windows xp,ROR 3.0.3,SQLite3)。

当我将应用程序移动到生产服务器(FreeBSD 8.2-RELEASE,Apache 2.2,ROR 3.0.4,MySQL)时,出现了此错误,但仅限于新的注册页面。

当我尝试登录时(数据库中没有用户),密码检查似乎有效(它说密码不正确,这很好)。

问题仅发生在生产服务器上,开发服务器没问题。它可能是什么?

谢谢!

[edit]添加09.08.2011:

routes.rb中:

  #USERS
  get "/user/stat"
  devise_for :users do
    get "/login" => "devise/sessions#new"
    get "/logout" => "devise/sessions#destroy"
  end
  get "/users" => "user#index"
  resources :user

registations_controller.rb:

  # GET /resource/sign_up
  def new
    build_resource({})
    render_with_scope :new
  end

  protected

    # Build a devise resource passing in the session. Useful to move
    # temporary session data to the newly created user.
    def build_resource(hash=nil)
      hash ||= params[resource_name] || {}
      self.resource = resource_class.new_with_session(hash, session)
    end

日志/ production.log:

Started GET "/users/sign_up" for 192.168.5.7 at 2011-08-09 13:40:31 +0400
  Processing by Devise::RegistrationsController#new as HTML
  SQL (31.7ms)  SHOW TABLES
Completed   in 33ms

NoMethodError (undefined method `new_with_session' for #<Class:0x284ac6a8>):
  app/controllers/registrations_controller.rb:71:in `build_resource'
  app/controllers/registrations_controller.rb:8:in `new'

1 个答案:

答案 0 :(得分:0)

将app目录的所有者更改为与HTTPD进程所有者相同的用户:

$ chown -R <username> <your_app_dir>

e.g。

$ chown -R www /usr/local/www/apache22/data

并更新Devise:

$ bundle update

Gemfile指定最新的Devise版本:

gem 'devise'

这对我有用。

相关问题