---
title: "Discussion on \"ActiveSupport#presence method\" | Hashnode"
description: "Discussion on \"ActiveSupport#presence method\". We want to set the default role to guest if both params[:role] is blank. By blank I mean either these values hold nil or '' .\nOld way\ndef role(params: {})\n    params[:role].present? ? params[:role] : 'guest'\nend\n\nUsing ActiveSupport#presence\ndef role..."
url: "https://hashnode.com/posts/activesupportpresence-method/648a74323318514ddb6a198a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [ActiveSupport#presence method](https://blog.przbadu.dev/activesupportpresence-method?utm_source=hashnode&utm_medium=feed)

We want to set the default role to guest if both params\[:role\] is blank. By blank I mean either these values hold nil or '' . Old way def role(params: {}) params\[:role\].present? ? params\[:role\] : 'guest' end Using ActiveSupport#presence def role...

Jun 15, 2023 · 1 min read · blog.przbadu.dev  
Read the article

-   [#ruby](https://hashnode.com/tag/ruby)
-   [#ruby-on-rails](https://hashnode.com/tag/ruby-on-rails)
-   [#presence](https://hashnode.com/tag/presence)

## Written by

[Pushpa Raj Badu](https://hashnode.com/@przbadu)

@przbadu

  
[View profile](https://hashnode.com/@przbadu)

Fullstack web developer

I am a full-stack Ruby on Rails developer with experience in PostgreSQL, Docker, Heroku, and performance optimization. I love exploring new technology stacks and have recently developed an interest in mobile app development using Flutter. My skills in test-driven development and fixing security vulnerabilities have helped me deliver high-quality, reliable code. I am also currently learning about machine learning and its applications in real-world problem-solving. I bring a unique combination of technical expertise, creative problem-solving, and a passion for learning to any team. I am committed to delivering elegant and efficient software solutions and excited to contribute to an innovative and dynamic team that shares this vision.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
