I am building a app for trading books where a user lists books that
they want to trade and those then want to get.
I have a Book model with title, author and condition as attributes.
The “condition” attribute (good, fair, poor) is set by the user for
the books they have to trade when the item is listed. This attribute
is not set for books that a user is looking to get. A “list” method
displays all the books as follows:
<% for column in Book.content_columns %>
<%= column.human_name %>: <%=h @book.send(column.name) %>
<% end %>
What I am looking for is a way NOT to display the “condition” field
when dealing with books that I “want” but not for the other. What’s a
good way to do that in the view in the “for” loop above?
Thanks, Roupen N.
nahabed wrote:
I am building a app for trading books where a user lists books that
they want to trade and those then want to get.
I have a Book model with title, author and condition as attributes.
The “condition” attribute (good, fair, poor) is set by the user for
the books they have to trade when the item is listed. This attribute
is not set for books that a user is looking to get. A “list” method
displays all the books as follows:
<% for column in Book.content_columns %>
<%= column.human_name %>: <%=h @book.send(column.name) %>
<% end %>
What I am looking for is a way NOT to display the “condition” field
when dealing with books that I “want” but not for the other. What’s a
good way to do that in the view in the “for” loop above?
Thanks, Roupen N.
To tell the truth , i didn’t take what you meant, but i guess sth…
<% for column in Book.content_columns %>
<% unless column.name == “condition” && @book.is_looking_to_get%>
<%= column.human_name %>: <%=h @book.send(column.name) %>
<% end %>
<% end %>
try this
contact me and make a friend ^^