2014-04-18 3 views
0

사용자 정보를 수정하려고하면 마지막에 인증 토큰을 표시하는 URL을 제외하고 '업데이트'를 클릭 한 후에 아무런 변화가 없습니다. 내가 omniauth 가입뿐만 아니라, 별도의 편집보기에 대한 사용자 정의 유증 컨트롤러를 추가하기 위해 고안 경로를 변경사용자 프로필을 편집 할 수 없습니다.

Unpermitted parameters: utf8, _method, authenticity_token, user, commit, format 

: 로그는이처럼 보이는 허가되지 않은 매개 변수 오류를 보여줍니다. 라우트 : 여기

devise_for :users, path_names: {sign_in: "login", sign_out: "logout"}, 
       controllers: {omniauth_callbacks: "omniauth_callbacks"} 

devise_scope :user do 
get "/info" => "registrations#info" 
end 

사용자 정의 고안 컨트롤러 : 여기

class RegistrationsController < Devise::RegistrationsController 
def info 
    @user = current_user 
    if @user 
     render :info 
    else 
     redirect_to root_path 
    end 
    end 

    def update 
    @user = User.find(params[:id]) 


    @user.update_without_password(devise_parameter_sanitizer.for(:account_update)) 
redirect_to user_path(current_user) 

end 
protected 

def after_sign_up_path_for(resource) 
    '/info' 
    end 
end 

및 편집이다 :, 채팅 세션 당으로

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put}) do |f| %> 

<%= f.input :name %> 
<%= f.input :email %> 

<% end %> 
+0

params' 해시와'허가되지 않은 params' 경고'를 포함하여 관련 서버 로그와 질문을 업데이트하시기 바랍니다. –

+0

업데이트되었습니다. 감사합니다. 그게 니가 원하는거야? – user2759575

+0

채팅에 대해 이야기 해 봅시다. http://chat.stackoverflow.com/rooms/48530/ror –

답변

1

영업 이익으로 두 forms했다 :

<form class="form-horizontal"> 
<form accept-charset="UTF-8" action="/users" class="simple_form user" enctype="multipart/form-data" id="edit_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="om7WhULk2OPgMGwjbTz5h79BqUlkr4lF9aRVDaOxUhs=" /></div> 
아래와 같이 업데이트 작업 암호없이 업데이트하기 위해, 또한

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put}, :class =>"form-horizontal") do |f| %> 

사용자 레코드를 변경 : 10

<form class="form-horizontal">를 제거하고 아래 simple_form_for 기존에 클래스를 추가하는 제안

def update 
    # For Rails 4 
    account_update_params = devise_parameter_sanitizer.sanitize(:account_update) 

    # required for settings form to submit when password is left blank 
    if account_update_params[:password].blank? 
     account_update_params.delete("password") 
     account_update_params.delete("password_confirmation") 
    end 

    @user = User.find(current_user.id) 
    if @user.update_attributes(account_update_params) 
     set_flash_message :notice, :updated 
     # Sign in the user bypassing validation in case his password changed 
     sign_in @user, :bypass => true 
     redirect_to user_path(current_user) 
    else 
     render "edit" 
    end 
    end 

UPDATE를

현재 전화가 "Devise :: RegistrationsController # update by HTML 처리 중"으로 진행됩니다. Devise::RegistrationsController 대신하여 RegistrationsController 업데이트로 아래 routes.rb는 :

devise_for :users, path_names: {sign_in: "login", sign_out: "logout"}, 
controllers: {omniauth_callbacks: "omniauth_callbacks", registrations: :registrations} 
관련 문제