Displaying Status In View - Rails
|Added at||2017-01-04 14:01|
In my rails application I have a model called JobPosting. A job posting has a status, it can be either:
I implemented these statuses using ActiveRecord::Enum like so:
Now I would like to display a different user interface element that is dependant on the status of the job posting. i.e.
For the waiting approval status I want:
And for the open status I want:
Note that there is different text and the class is different as the element is styled differently for the different cases. In my index.html.erb, where this styling needs to happen, I could just do a bunch of embedded ruby if statements and check the status of the posting and display the desired element, like so:
I feel as if that is not very DRY, is there a better way?
Alternatively, I could create partial and have the logic stored in that and just render the partial, but again is that how it is done?