<%= @model_class %>

<%= link_to 'Add new Record', model_new_path(:model_class => @model_class), class: 'btn btn-success' %>
<% @model_class.constantize.column_names.each do |k| %> <% end %> <% @model_pagination.each do |model_data| %> <% @model_class.constantize.column_names.each do |model_column_name| %> <% end %> <% end %>
<%= k %>Actions Association Relationship
<%= 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)%> <%= 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 %>
Download: <%= link_to 'CSV', download_csv_path(model_class: @model_class), format: :csv %> <%= link_to 'JSON', download_json_path(model_class: @model_class), format: :json %> <%= link_to 'XML', download_xml_path(model_class: @model_class), format: :xml %>