foreach - Pass .each loop reference object in Ruby on Rails -


i writing code in ruby on rails creating dynamic rows in table involves .each loop. want pass .each loop reference object gives me error.

following code:

<% pworkflows.workflow_executions_list.each |wf| %>   <tr>     <td><%= wf.execution_status %></td>     <td>       <% if(wf.start_timestamp != nil) %>         <%= wf.start_timestamp.localtime; %> utc       <% end %>     </td>     <td><%= wf.close_status %></td>     <td><%= wf.execution.run_id %></td>     <td><%= button_to "details",{ :controller => "pages", :action => "mainpage",:rulesetinstance=>rinsid, :ndetails=>wf} %></td>   </tr> <% end %> 

:ndetails=>wf gives error. wf not being recognized correct syntax send. please suggest way.

the error being:

undefined local variable or method `id' #<comrulemanagement::workflowexecutionobject:0x00003da1751528> 

when this

<%= button_to "details",{ :controller => "pages", :action => "mainpage",:rulesetinstance=>rinsid, :ndetails=>wf} %> 

you building html tag. (since button_to html helper). options pass through, in instance ":rulesetinstance" , ":ndetails" used make attributes in element, rulesetinstance="123". however, if pass wf object through, rails call to_s on it, , you'll end looks ndetails="#<wf:0x7f518dfc6e68>". not want in html element. should calling method of wf object instead?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -