본문으로 바로가기

Ruby on Rails 7.1 에서 devise 사용하기

category Studies/RubyonRails 2022. 1. 16. 17:32

| 설치

heartcombo/devise: Flexible authentication solution for Rails with Warden. (github.com)

 

GitHub - heartcombo/devise: Flexible authentication solution for Rails with Warden.

Flexible authentication solution for Rails with Warden. - GitHub - heartcombo/devise: Flexible authentication solution for Rails with Warden.

github.com

 rails db:migrate 까지 이전 버전과 동일하다.

  

그러나 자동으로 추가되던 컨트롤러가 최근 버전부터는 따로 명령어를 입력해야 추가 된다.

rails generate devise:controllers [scope]

 

| 메소드 변경

link_to 메소드 사용 방식이 변경되었다.

<%= link_to "Sign out", destroy_user_session_path, 'data-turbo-method': :delete, class:"nav-link" %>

method: :delete => 'data-turbo-method': :delete

 

| 헬퍼

<% if user_signed_in? %>
//코드
<%else%>
//코드
<%end%>

위와 같은 방식으로 간편하게 devise 헬퍼를 사용하여 view 구성이 가능 하다.