사용자 모델에 사용자 정의 필드를 추가했는데, 현재 사용자 객체에서 가져오려고 했을 때 해당 필드가 표시되지 않았습니다. 사용자 정의 필드를 가져오는 방법은 무엇일까요?
아래 코드를 시도해 보았습니다.
require_dependency 'user_serializer'
class ::UserSerializer
attributes :custom_thumbnail_style_dropdown
def custom_thumbnail_style_dropdown
object.custom_fields[custom_thumbnail_style_dropdown]
end
end
정의 부분에서 object.custom_thumbnail_style_dropdown을 시도해 보았지만 작동하지 않았습니다.
또한 아래 코드도 시도해 보았습니다.
add_to_serializer(:user, :custom_thumbnail_style_dropdown, false) do
object.custom_thumbnail_style_dropdown
end