Backend/RubyOnRails

💡 원본 글 : https://blog.appsignal.com/2021/07/07/general-ruby-on-rails-problems-and-takeaways.html General Ruby on Rails Problems and Takeaways | AppSignal Blog In this last part of the Rails Patterns and Anti-patterns series, I'll be going over the most common problems I've encountered while building and shipping Ruby on Rails applications. blog.appsignal.com Ruby On Rails 패턴 및 안티 패턴 시리즈 마지막 파트에 ..
💡 원본글 : https://blog.appsignal.com/2021/04/14/ruby-on-rails-controller-patterns-and-anti-patterns.html Ruby on Rails Controller Patterns and Anti-patterns | AppSignal Blog In this part of the series on Rails patterns and anti-patterns, we are going to analyze the final part of the MVC (Model-View-Controller) design pattern — the Controller. blog.appsignal.com Ruby On Rails 패턴 및 안티 패턴 시리즈의 네 번째 편..
💡 원본글 : https://blog.appsignal.com/2021/02/10/ruby-on-rails-view-patterns-and-anti-patterns.html Ruby on Rails View Patterns and Anti-patterns | AppSignal Blog Rails views are sometimes amazing and fast, and at other times, they can have all sorts of issues. If you want to increase confidence over how you handle your views, then this blog post is for you. blog.appsignal.com Ruby On Rails 패턴과 안티패..
💡 원본글 : https://blog.appsignal.com/2020/11/18/rails-model-patterns-and-anti-patterns.html Ruby on Rails Model Patterns and Anti-patterns | AppSignal Blog If you're struggling with models, this blog post is for you. We will quickly go through the process of putting your models on a diet and finish strongly with some things to avoid when writing migrations. blog.appsignal.com Ruby on Rails 패턴 및 안티..
💡 원본 글: https://blog.appsignal.com/2020/08/05/introduction-to-ruby-on-rails-patterns-and-anti-patterns.html Introduction to Ruby on Rails Patterns and Anti-patterns | AppSignal Blog Dig into the basics of design patterns and anti-patterns. blog.appsignal.com Ruby On Rails 패턴 및 안티패턴 시리즈의 첫 번째 게시물에 오신 것을 환영합니다. 이 시리즈에서는 Rails 앱을 개발하는 동안 접할 수 있는 모든 종류의 패턴에 대해 자세히 살펴보겠습니다. 오늘 우리는 (디자인) 패턴이 무엇인지 보여주고..
NamedRoute의 _path vs _url 서론 RubyOnRails는 NamedRoute라는 쉽게 경로를 작성할 수 있는 방법을 제공합니다. # In config/routes.rb root to: 'blogs#index' # would recognize http://www.example.com/ as params = { controller: 'blogs', action: 'index' } # and provide these named routes root_url # => 'http://www.example.com/' root_path # => '/' routes를 작성할때 as라는 옵션을 제공해줘서 커스텀도 가능합니다. # In config/routes.rb get '/login', to: 'acc..
devise_invitable를 테스트 해보자. 🧐 서론 현재 회사에서 devise_invitable를 이용해 사용자에게 초대 이메일을 보내 가입을 시켜주고 있습니다. users/invitation/accept?invitation_token=abcdef 이러한 URL를 사용해 토큰을 제공해주고, 토큰이 유효가 된다면 토큰이 유효되었다는 안내를 보여주며, root_path로 이동시키고 있습니다. 이러한 플로우로 제공하다 보니, 사용자들이 다시 해당 서비스를 들어오려고 메일을 클릭하는 경우가 생기며, 유효하지 않는 토큰입니다. 라는 메시지와 같이 본인이 원하는 페이지를 보지 못하는 경우가 생겼습니다. 사용자가 원하는 페이지는 무조건 로그인을 해야 볼 수 있는 페이지인데, 로그인을 하지 않고 root_path..
Methods in Rails modules 해당 글은 Methods in Rails modules 을 번역한 글입니다. 모듈은 일반적으로 속성 값을 보유할수 있도록 상수를 그룹화 하는 데 사용합니다. 아래 예제에서 Order 클래스와 status 속성이 있다고 해봅시다. Status는 pending(보류), confirmed(확인), cacelled(취소) 등을 가지고 있습니다. classOrder < ApplicationRecord module Status PENDING='Pending' CONFIRMED='Confirmed' CANCELLED='Cancelled' DECLINED='Declined' COMPLETED='Completed..
How Rails Sessions Work Rails App에 누가 방문했는지 알수 없다면 어떻게 될까요? 만약 같은 사람이 두개의 다른 페이지를 요청했다는 사실을 몰랐다면? 만약 응답을 반환하자 마자 저장한 모든 데이터가 사라진다면? 이런 경우에는 대부분 정적 사이트에는 적합할수 있습니다. 그러나 대부분 앱은 사용자에 대한 일부 데이터를 저장할 수 있어야 합니다. ID, 언어, 아이패드에서 데스크톱 버전으로 보고싶어하는지 등등에 대한 여부가 저장해야 할 데이터 일겁니다. session 은 이러한 한 개 이상의 요청에 대해 보관하려는 작은 데이터를 저장하는데 완벽한 장소입니다. 세션은 사용하기 굉장히 쉽습니다. session[:current_user_id] = @user.**id** 그러나 이것은 약간의..
[RubyOnRails Guides] Active Record Query Interface - 2편 💼 서론 RubyOnRails Guides Active Record Basics 를 참고해 작성한 글입니다. Ruby version은 2.6.3을 사용합니다. Ruby On Rails version은 5.2.1을 사용합니다. 1편에서는 단건 및 복수 조회, 조건, 정렬, 그룹 등을 정리했습니다 (참고링크) Locking Records for Update DB 트랜잭션이 2개 이상 진행될 경우 프로세스 내에서 작업하는 쓰레드 자원이 꼬여 race codnition(경쟁 상태) 문제가 발생해 우리가 기대한 처리결과가 나오지 않을 경우가 있다. 따라서 우리는 이런 경우 Thread Safe 하게 해줘야 하는데,..
Seyun(Marco)
'Backend/RubyOnRails' 카테고리의 글 목록