fix devise integration for rails 4
This commit is contained in:
parent
dfaadc691e
commit
f4456d06ef
4 changed files with 18 additions and 16 deletions
|
@ -1,10 +0,0 @@
|
|||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
protected
|
||||
def after_sign_up_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
|
||||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,7 @@
|
|||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
before_filter :configure_sign_up_params, only: [:create]
|
||||
before_filter :configure_account_update_params, only: [:update]
|
||||
|
||||
protected
|
||||
def after_sign_up_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
|
@ -7,4 +10,14 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
end
|
||||
|
||||
private
|
||||
def configure_sign_up_params
|
||||
devise_parameter_sanitizer.for(:sign_up) << [:name, :joinedwithcode]
|
||||
end
|
||||
|
||||
def configure_account_update_params
|
||||
puts devise_parameter_sanitizer_for(:account_update)
|
||||
devise_parameter_sanitizer.for(:account_update) << [:image]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,9 +22,9 @@ class UsersController < ApplicationController
|
|||
def update
|
||||
@user = current_user
|
||||
|
||||
if params[:user][:password] == "" && params[:user][:password_confirmation] == ""
|
||||
if user_params[:password] == "" && user_params[:password_confirmation] == ""
|
||||
# not trying to change the password
|
||||
if @user.update_attributes(params[:user])
|
||||
if @user.update_attributes(user_params.except(:password, :password_confirmation))
|
||||
if params[:remove_image] == "1"
|
||||
@user.image = nil
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ class UsersController < ApplicationController
|
|||
# trying to change the password
|
||||
correct_pass = @user.valid_password?(params[:current_password])
|
||||
|
||||
if correct_pass && @user.update_attributes(params[:user])
|
||||
if correct_pass && @user.update_attributes(user_params)
|
||||
if params[:remove_image] == "1"
|
||||
@user.image = nil
|
||||
end
|
||||
|
@ -101,8 +101,7 @@ class UsersController < ApplicationController
|
|||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :email, :image, :password,
|
||||
:password_confirmation, :code, :joinedwithcode, :remember_me)
|
||||
params.require(:user).permit(:name, :email, :image, :password, :password_confirmation)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require File.expand_path('../boot', __FILE__)
|
|||
|
||||
require 'rails/all'
|
||||
|
||||
Bundler.require(:default, Rails.env)
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Metamaps
|
||||
class Application < Rails::Application
|
||||
|
|
Loading…
Reference in a new issue