Devise - NoMethodError in Registrations#new controller
Every开发者_Python百科thing worked fine on my development machine (windows xp, ROR 3.0.3, SQLite3).
When I moved the application to the production server (FreeBSD 8.2-RELEASE, Apache 2.2, ROR 3.0.4, MySQL), this error appeared, but only on new registration page.
When I try to login (there are no users in the database), password check seems to work (it says that password incorrect, which is fine).
The problem occurs only on the production server, no problem on the developement server. What could it be?
Thanks!
[edit] added 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
log/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'
Change the owner of the app directory to the same user as HTTPD process owner:
$ chown -R <username> <your_app_dir>
e.g.
$ chown -R www /usr/local/www/apache22/data
and update Devise:
$ bundle update
Gemfile specifies the latest Devise version:
gem 'devise'
That worked for me.
精彩评论