In my application every post that is submitted by users will to be approved or denied. I have a Post model and in my posts table, I have columns: approved & denied and both of them are boolean.
In my view I do:
= is_true?(post.approved)? 'APPROVED' : 'PENDING'
NB: is_true? is a helper I have in my ApplicationHelper
def is_true?(object)
object == true
end
As the code says, if post has been approved, it will be APPROVED, otherwise is PENDING. This works fine, but I don't how to add the DENIED in my inline condition.
So basically IF post is approved it will be APPROVED, ELSE IF post has nor been approved or denied it will be PENDING & IF post has been denied it will be DENIED.
I know I can write the condition in my view, but the code becomes ugly and I am fan of inline conditions and clean way.
How can I make it clean?
Aucun commentaire:
Enregistrer un commentaire