이상한 행동을합니다. 빨간색 또는 오류 메시지를 표시하지만 녹색 또는 성공 메시지를 표시하지 않습니다.성공한 메시지가 표시되지 않음
사용자가 로그인했는지 여부에 따라 로그인 페이지 또는 홈 페이지로 리디렉션하도록 라우팅 및 컨트롤러를 변경 한 후에 이런 일이 발생했습니다.
는 그래서 routes.rb 이제이 있습니다
devise_for :users
root :to => "questions#redirect_on_visit"
match 'home', :to => "questions#index"
및 컨트롤러 :
before_filter :authenticate_user!, :except => [:redirect_on_visit]
def redirect_on_visit
if user_signed_in?
redirect_to home_path
else
redirect_to new_user_session_path
end
end
또한 변경된 응용 프로그램 컨트롤러를 로그인/로그 아웃 한 후 해당 페이지로 리디렉션 :
protected
def after_sign_in_path_for(resource)
stored_location_for(:user) || root_path
end
private
def after_sign_out_path_for(resource)
stored_location_for(:user) || root_path
end
로그인하거나 로그 아웃 할 때 플래시 객체에서 무엇을 볼 수 있습니까? 그 정보를'flash [: notice]'로 쓰고,'flash [: success] '가 아니라고 쓰는 것 같아요. – Viren
예! 그것은 물론'flash [: notice]'입니다. 성공한 메시지 란 사용자가 로그인하거나 성공적으로 로그 아웃했다는 메시지를 말합니다. Devise는 녹색 배경으로 표시합니다. – Humming
배경색은 확실하지만 플래쉬 메시지가'devise.yml' ('config/locales' 디렉토리) 파일을 검사하면 더 많은 통찰력을 얻을 수 있습니다 – Viren