<% @model_class.constantize.column_names.each do |model_column_name| %>
<%= model_data.send(model_column_name.to_sym).class=='String' ? model_data.send(model_column_name.to_sym).truncate(14) : model_data.send(model_column_name.to_sym).to_s.truncate(14)%>
|
<% end %>
<%= link_to 'View', model_show_path(model_class: @model_class, model_object_id: model_data.id, page: @page), class: 'btn btn-info' %>
<%= link_to 'Edit', model_edit_path(model_class: @model_class, model_object_id: model_data.id), class: 'btn btn-warning' %>
<%= link_to 'Delete', model_destroy_path(model_class: @model_class, model_object_id: model_data.id), method: :delete, data: {confirm: "Are you sure?"}, class: 'btn btn-danger' %>
|
<% relationship_hash ={}, a1=[], a2=[]%>
<% @model_class.constantize.reflect_on_all_associations.each do |reflection|%>
<% reflection.options[:polymorphic] ? a1.push(reflection.active_record.name) : a2.push(reflection.klass.name) %>
<% end %>
<% relationship_hash = @model_class.constantize.reflect_on_all_associations.map{|x| [x.name, x.macro]}.zip(a1+a2).inject({}){|h,e| h[e.first] = e.last; h}%>
<% if relationship_hash.empty? %>
<%= 'Sorry no relationship!'%>
<% else %>
<% relationship_hash.each do |k,v| %>
<%= link_to "#{k.last} #{k.first} |" , associations_index_path(associated_model: k.first, model_object_id: model_data.id, model_class: @model_class, associated_model_class: v, macro: k.last) %>
<% end %>
<% end %>
|
<% end %>