if statement messing my table

Hey y'all was working on a task management app just to practice (I'm a total noob here), but when styling it my I've got an if statement inside of a bootstrap table that gets all f'ed up when the if is inside the table the second I take it out everything lines up again.

Here's my code:

Here's what's doing (see how the items aren't aligning):

I've tried giving them each classes of they're own and trying to align it in CSS but that seems like it's not doing anything.

Any ideas why this is happening and what the solution may be?
Rails 4.2.5 and bootstrap-sass gem

Thanks in advance any help is greatly appreciated.

1 thought on “if statement messing my table”

  1. It probably has something to do with the width and align attributes not being set for the td elements in the else statement.

    Having said that, I wouldn’t hard code the width and alignment in the HTML, but set a CSS class on the td elements and then set the width and align properties in the CSS. I would also refactor some code into a reusable partial since the structure is the same in both the if and else blocks and you want to keep code as DRY as possible.

    EDIT: I looked at the code again and it looks like the only difference is the opacity and strike through of the description? I would instead refactor to have the if statement confined to the description text.


Leave a Comment