Created
April 10, 2011 05:07
-
-
Save ch1ago/912065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in Devise::RegistrationsController#new | |
undefined method `new_with_session' for #<Class:0xb2b59fc> | |
Rails.root: /home/usuario/apps/ex2 | |
Application Trace | Framework Trace | Full Trace | |
app/controllers/devise/registrations_controller.rb:71:in `build_resource' | |
app/controllers/devise/registrations_controller.rb:8:in `new' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Devise::RegistrationsController < ApplicationController | |
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ] | |
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy] | |
include Devise::Controllers::InternalHelpers | |
# GET /resource/sign_up | |
def new | |
build_resource({}) | |
render_with_scope :new | |
end | |
# POST /resource | |
def create | |
build_resource | |
if resource.save | |
if resource.active_for_authentication? | |
set_flash_message :notice, :signed_up if is_navigational_format? | |
sign_in(resource_name, resource) | |
respond_with resource, :location => redirect_location(resource_name, resource) | |
else | |
set_flash_message :notice, :inactive_signed_up, :reason => resource.inactive_message.to_s if is_navigational_format? | |
expire_session_data_after_sign_in! | |
respond_with resource, :location => after_inactive_sign_up_path_for(resource) | |
end | |
else | |
clean_up_passwords(resource) | |
respond_with_navigational(resource) { render_with_scope :new } | |
end | |
end | |
# GET /resource/edit | |
def edit | |
render_with_scope :edit | |
end | |
# PUT /resource | |
def update | |
if resource.update_with_password(params[resource_name]) | |
set_flash_message :notice, :updated if is_navigational_format? | |
sign_in resource_name, resource, :bypass => true | |
respond_with resource, :location => after_update_path_for(resource) | |
else | |
clean_up_passwords(resource) | |
respond_with_navigational(resource){ render_with_scope :edit } | |
end | |
end | |
# DELETE /resource | |
def destroy | |
resource.destroy | |
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) | |
set_flash_message :notice, :destroyed if is_navigational_format? | |
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) } | |
end | |
# GET /resource/cancel | |
# Forces the session data which is usually expired after sign | |
# in to be expired now. This is useful if the user wants to | |
# cancel oauth signing in/up in the middle of the process, | |
# removing all OAuth session data. | |
def cancel | |
expire_session_data_after_sign_in! | |
redirect_to new_registration_path(resource_name) | |
end | |
protected | |
=begin | |
# 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 | |
=end | |
# The path used after sign up. You need to overwrite this method | |
# in your own RegistrationsController. | |
def after_sign_up_path_for(resource) | |
after_sign_in_path_for(resource) | |
end | |
# Overwrite redirect_for_sign_in so it takes uses after_sign_up_path_for. | |
def redirect_location(scope, resource) #:nodoc: | |
stored_location_for(scope) || after_sign_up_path_for(resource) | |
end | |
# The path used after sign up for inactive accounts. You need to overwrite | |
# this method in your own RegistrationsController. | |
def after_inactive_sign_up_path_for(resource) | |
root_path | |
end | |
# The default url to be used after updating a resource. You need to overwrite | |
# this method in your own RegistrationsController. | |
def after_update_path_for(resource) | |
if defined?(super) | |
ActiveSupport::Deprecation.warn "Defining after_update_path_for in ApplicationController " << | |
"is deprecated. Please add a RegistrationsController to your application and define it there." | |
super | |
else | |
after_sign_in_path_for(resource) | |
end | |
end | |
# Authenticates the current scope and gets a copy of the current resource. | |
# We need to use a copy because we don't want actions like update changing | |
# the current user in place. | |
def authenticate_scope! | |
send(:"authenticate_#{resource_name}!", true) | |
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment