Ruby loop - determining value -


i looping through items, names should self explanatory:

  <% [@in_force_item, @draft_item, @historical_items].compact.flatten.each |item| %>       <tr>         <td>           <label><input class="select"  type="checkbox" /></label>         </td>        <td>           <% if item == @draft_item %>             <div> <%= link_to('', edit_account_item_path(@account, @draft_loa_item), class: 'black-icon-color') %></div>           <% else %>                   <i class="lock"></i>               <span class='black-icon-color'></span>           <% end %>         </td>         <td>           <% updated_at = datetime_to_string item.updated_at %>            <%= link_to(updated_at, account_item_path(@account, item)) %>         </td>         <td><%= lifecycle_label(item) %></td>       </tr>   <% end %> 

the line having trouble checking if item draft.

<% if item == @draft_item %> 

this doesn't seem work , i'm not sure how go it. need method in item model check if draft or not?

how can achieve this?

edit: model has this:

    composite_draft = [lifecycle_draft_num, lifecycle_returned_num] lifecycle_draft_name = 'draft' lifecycle_draft_num = 0  lifecycle_returned_name = 'returned'   lifecycle_returned_num = 2 

so should able use like:

item.lifecycle_num.???? 

your items should have states,- way you'd able call item.draft? method , also, wouldn't need 3 separate instance variables. please check aasm gem more information.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -