model_info 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +34 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/model_info/application.js +15 -0
- data/app/assets/javascripts/model_info/associations.js +2 -0
- data/app/assets/javascripts/model_info/fetch_model_infos.js +2 -0
- data/app/assets/stylesheets/model_info/application.css +15 -0
- data/app/assets/stylesheets/model_info/associations.css +4 -0
- data/app/assets/stylesheets/model_info/bootstrap.css +6566 -0
- data/app/assets/stylesheets/model_info/bootstrap.min.css +5 -0
- data/app/assets/stylesheets/model_info/fetch_model_infos.css +4 -0
- data/app/controllers/model_info/application_controller.rb +23 -0
- data/app/controllers/model_info/associations_controller.rb +49 -0
- data/app/controllers/model_info/models_controller.rb +54 -0
- data/app/helpers/model_info/application_helper.rb +4 -0
- data/app/helpers/model_info/associations_helper.rb +4 -0
- data/app/views/layouts/model_info/_header.html.erb +7 -0
- data/app/views/layouts/model_info/_models_header.html.erb +5 -0
- data/app/views/layouts/model_info/application.html.erb +15 -0
- data/app/views/model_info/associations/edit.html.erb +14 -0
- data/app/views/model_info/associations/index.html.erb +50 -0
- data/app/views/model_info/associations/new.html.erb +24 -0
- data/app/views/model_info/associations/show.html.erb +19 -0
- data/app/views/model_info/models/display.html.erb +49 -0
- data/app/views/model_info/models/edit.html.erb +14 -0
- data/app/views/model_info/models/new.html.erb +21 -0
- data/app/views/model_info/models/show.html.erb +19 -0
- data/config/routes.rb +19 -0
- data/lib/model_info/engine.rb +5 -0
- data/lib/model_info/version.rb +3 -0
- data/lib/model_info.rb +3 -0
- data/lib/tasks/model_info_tasks.rake +4 -0
- metadata +118 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
<h3><%= @model_class.humanize %></h3>
|
2
|
+
<table class="table table-hover">
|
3
|
+
<tr>
|
4
|
+
<% @model_class.constantize.column_names.each do |k| %>
|
5
|
+
<th><%= k %></th>
|
6
|
+
<% end %>
|
7
|
+
<th>Actions</th>
|
8
|
+
<th>Association Relationship</th>
|
9
|
+
</tr>
|
10
|
+
<% @model_pagination.each do |model_data| %>
|
11
|
+
<tr>
|
12
|
+
<% @model_class.constantize.column_names.each do |model_column_name| %>
|
13
|
+
<td>
|
14
|
+
<%= 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)%>
|
15
|
+
</td>
|
16
|
+
<% end %>
|
17
|
+
<td>
|
18
|
+
<%= link_to 'view', model_show_path(model_class: @model_class, model_object_id: model_data.id, page: @page), class: 'btn btn-info' %>
|
19
|
+
<%= link_to 'edit', model_edit_path(model_class: @model_class, model_object_id: model_data.id), class: 'btn btn-warning' %>
|
20
|
+
<%= 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' %>
|
21
|
+
</td>
|
22
|
+
<td>
|
23
|
+
<% relationship_hash ={}, a1=[], a2=[]%>
|
24
|
+
<% @model_class.constantize.reflect_on_all_associations.each do |reflection|%>
|
25
|
+
<% reflection.options[:polymorphic] ? a1.push(reflection.active_record.name) : a2.push(reflection.klass.name) %>
|
26
|
+
<% end %>
|
27
|
+
<% relationship_hash = @model_class.constantize.reflect_on_all_associations.map{|x| [x.name, x.macro]}.zip(a1+a2).to_h %>
|
28
|
+
|
29
|
+
<% if relationship_hash.empty? %>
|
30
|
+
<%= 'Sorry no relationship!'%>
|
31
|
+
<% else %>
|
32
|
+
<% relationship_hash.each do |k,v| %>
|
33
|
+
<%= 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) %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
</td>
|
37
|
+
</tr>
|
38
|
+
<% end %>
|
39
|
+
</table>
|
40
|
+
<div align="right">
|
41
|
+
<b><%= link_to 'Add new Record', model_new_path(:model_class => @model_class), class: 'btn btn-success' %></b>
|
42
|
+
</div>
|
43
|
+
<nav>
|
44
|
+
<ul class="pagination">
|
45
|
+
<li><%= paginate @model_pagination %></li>
|
46
|
+
<%= page_entries_info @model_pagination %>
|
47
|
+
</ul>
|
48
|
+
</nav>
|
49
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h3>Update Your Model's Data</h3>
|
2
|
+
<div class="jumbotron">
|
3
|
+
<%= form_for @model_data, url: model_update_path(model_class: @model_class), method: :patch do |f| %>
|
4
|
+
<% (@model_class.column_names - %w(serialized_options created_at updated_at)).each do |resource_field| %>
|
5
|
+
<div class="form-group">
|
6
|
+
<%= f.label resource_field %>
|
7
|
+
<div class="form-group">
|
8
|
+
<%= f.text_field resource_field %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
<%= f.submit 'Save Changes', class:"btn btn-primary" %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h3>Add New Record</h3>
|
2
|
+
<div class="jumbotron">
|
3
|
+
<%= form_for @model_data, url: model_create_path, method: :post do |f| %>
|
4
|
+
<% (@model_data.class.column_names - %w(id serialized_options created_at updated_at)).each do |data_field| %>
|
5
|
+
<div class="form-group">
|
6
|
+
<%= f.label data_field %>
|
7
|
+
<%= hidden_field_tag :model_class, @model_class %>
|
8
|
+
<div class="form-group">
|
9
|
+
<%= f.text_field data_field %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
<%= f.submit 'Save Changes', class:"btn btn-primary" %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h3>View Your Data</h3>
|
2
|
+
<table class="table table-hover table-bordered">
|
3
|
+
<tr>
|
4
|
+
<th>Attribute</th>
|
5
|
+
<th>Value</th>
|
6
|
+
</tr>
|
7
|
+
<% @model_class.column_names.each do |model_column_name| %>
|
8
|
+
<tr>
|
9
|
+
<th><%= model_column_name %></th>
|
10
|
+
<td><%= @model_data.send(model_column_name) %></td>
|
11
|
+
</tr>
|
12
|
+
<% end %>
|
13
|
+
<tr>
|
14
|
+
<th>Actions</th>
|
15
|
+
<td>
|
16
|
+
<%= link_to 'Back', :back %>
|
17
|
+
</td>
|
18
|
+
</tr>
|
19
|
+
</table>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ModelInfo::Engine.routes.draw do
|
2
|
+
|
3
|
+
get 'model_display', to: 'models#display'
|
4
|
+
get 'models',to: 'models#index'
|
5
|
+
get 'model_new',to: 'models#new'
|
6
|
+
post 'model_create',to: 'models#create'
|
7
|
+
get 'model_show',to: 'models#show'
|
8
|
+
get 'model_edit',to: 'models#edit'
|
9
|
+
patch 'model_update',to: 'models#update'
|
10
|
+
delete 'model_destroy', to: 'models#destroy'
|
11
|
+
|
12
|
+
get 'associations_index', to: 'associations#index'
|
13
|
+
get 'association_new',to: 'associations#new'
|
14
|
+
post 'association_create',to: 'associations#create'
|
15
|
+
get 'association_show',to: 'associations#show'
|
16
|
+
get 'association_edit',to: 'associations#edit'
|
17
|
+
patch 'association_update',to: 'associations#update'
|
18
|
+
delete 'association_destroy',to: 'associations#destroy'
|
19
|
+
end
|
data/lib/model_info.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: model_info
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nitanshu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bootstrap
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kaminari
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.16.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.16.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Description of ModelInfo.
|
56
|
+
email:
|
57
|
+
- nitanshu1991@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/javascripts/model_info/application.js
|
66
|
+
- app/assets/javascripts/model_info/associations.js
|
67
|
+
- app/assets/javascripts/model_info/fetch_model_infos.js
|
68
|
+
- app/assets/stylesheets/model_info/application.css
|
69
|
+
- app/assets/stylesheets/model_info/associations.css
|
70
|
+
- app/assets/stylesheets/model_info/bootstrap.css
|
71
|
+
- app/assets/stylesheets/model_info/bootstrap.min.css
|
72
|
+
- app/assets/stylesheets/model_info/fetch_model_infos.css
|
73
|
+
- app/controllers/model_info/application_controller.rb
|
74
|
+
- app/controllers/model_info/associations_controller.rb
|
75
|
+
- app/controllers/model_info/models_controller.rb
|
76
|
+
- app/helpers/model_info/application_helper.rb
|
77
|
+
- app/helpers/model_info/associations_helper.rb
|
78
|
+
- app/views/layouts/model_info/_header.html.erb
|
79
|
+
- app/views/layouts/model_info/_models_header.html.erb
|
80
|
+
- app/views/layouts/model_info/application.html.erb
|
81
|
+
- app/views/model_info/associations/edit.html.erb
|
82
|
+
- app/views/model_info/associations/index.html.erb
|
83
|
+
- app/views/model_info/associations/new.html.erb
|
84
|
+
- app/views/model_info/associations/show.html.erb
|
85
|
+
- app/views/model_info/models/display.html.erb
|
86
|
+
- app/views/model_info/models/edit.html.erb
|
87
|
+
- app/views/model_info/models/new.html.erb
|
88
|
+
- app/views/model_info/models/show.html.erb
|
89
|
+
- config/routes.rb
|
90
|
+
- lib/model_info.rb
|
91
|
+
- lib/model_info/engine.rb
|
92
|
+
- lib/model_info/version.rb
|
93
|
+
- lib/tasks/model_info_tasks.rake
|
94
|
+
homepage:
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.6
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Summary of ModelInfo.
|
118
|
+
test_files: []
|