Rails + ERB best practices question about conditional/Ruby logic placement

Hello, I’m making a simple web app in order to learn the Rails framework. I currently am appending my data as simple HTML elements and got down the idea of using ActiveRecord to fire out SQL commands to the DB.

I’m more concerned about where to put conditional statements in my Rails app. For example, I have a column in the DB with a boolean value, and depending on that bool I want to make an if-statement that can be either one string or the other to display on my ERB file.

Where should I place this conditional statement? I can achieve this in a few ways, and placing the if logic in the ERB is the easiest. But is this proper in regards to the professional setting? If I place this logic in my Model, I can’t access the params through the object’s methods OR the Model class’s methods.

I’m taking into consideration DRY and what I imagine the industry would want from a clean ERB file, which is mostly instance variables created within the Controller’s class.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs