quick_dry 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/quick_dry/application.js +15 -0
  6. data/app/assets/javascripts/quick_dry/quick_dry.js +2 -0
  7. data/app/assets/stylesheets/quick_dry/application.css +15 -0
  8. data/app/assets/stylesheets/quick_dry/quick_dry.css +4 -0
  9. data/app/assets/stylesheets/scaffold.css +56 -0
  10. data/app/controllers/quick_dry/application_controller.rb +4 -0
  11. data/app/controllers/quick_dry/quick_dry_controller.rb +195 -0
  12. data/app/helpers/quick_dry/application_helper.rb +4 -0
  13. data/app/helpers/quick_dry/quick_dry_helper.rb +4 -0
  14. data/app/views/layouts/quick_dry/application.html.erb +14 -0
  15. data/app/views/quick_dry/_form.html.erb +26 -0
  16. data/app/views/quick_dry/_model_table.html.erb +31 -0
  17. data/app/views/quick_dry/edit.html.erb +10 -0
  18. data/app/views/quick_dry/index.html.erb +1 -0
  19. data/app/views/quick_dry/new.html.erb +10 -0
  20. data/app/views/quick_dry/show.html.erb +12 -0
  21. data/config/routes.rb +14 -0
  22. data/lib/quick_dry/engine.rb +6 -0
  23. data/lib/quick_dry/version.rb +3 -0
  24. data/lib/quick_dry.rb +3 -4
  25. data/lib/tasks/quick_dry_tasks.rake +4 -0
  26. data/test/controllers/quick_dry/quick_dry_controller_test.rb +9 -0
  27. data/test/dummy/README.rdoc +28 -0
  28. data/test/dummy/Rakefile +6 -0
  29. data/test/dummy/app/assets/javascripts/application.js +13 -0
  30. data/test/dummy/app/assets/javascripts/comments.js +2 -0
  31. data/test/dummy/app/assets/javascripts/posts.js +2 -0
  32. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  33. data/test/dummy/app/assets/stylesheets/comments.css +4 -0
  34. data/test/dummy/app/assets/stylesheets/posts.css +4 -0
  35. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  36. data/test/dummy/app/controllers/application_controller.rb +5 -0
  37. data/test/dummy/app/controllers/comments_controller.rb +58 -0
  38. data/test/dummy/app/controllers/posts_controller.rb +58 -0
  39. data/test/dummy/app/helpers/application_helper.rb +2 -0
  40. data/test/dummy/app/helpers/comments_helper.rb +2 -0
  41. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  42. data/test/dummy/app/models/comment.rb +2 -0
  43. data/test/dummy/app/models/post.rb +2 -0
  44. data/test/dummy/app/views/comments/_form.html.erb +25 -0
  45. data/test/dummy/app/views/comments/edit.html.erb +6 -0
  46. data/test/dummy/app/views/comments/index.html.erb +27 -0
  47. data/test/dummy/app/views/comments/new.html.erb +5 -0
  48. data/test/dummy/app/views/comments/show.html.erb +14 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/app/views/posts/_form.html.erb +25 -0
  51. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  52. data/test/dummy/app/views/posts/index.html.erb +27 -0
  53. data/test/dummy/app/views/posts/new.html.erb +5 -0
  54. data/test/dummy/app/views/posts/show.html.erb +14 -0
  55. data/test/dummy/bin/bundle +3 -0
  56. data/test/dummy/bin/rails +4 -0
  57. data/test/dummy/bin/rake +4 -0
  58. data/test/dummy/config/application.rb +23 -0
  59. data/test/dummy/config/boot.rb +5 -0
  60. data/test/dummy/config/database.yml +25 -0
  61. data/test/dummy/config/environment.rb +5 -0
  62. data/test/dummy/config/environments/development.rb +37 -0
  63. data/test/dummy/config/environments/production.rb +78 -0
  64. data/test/dummy/config/environments/test.rb +39 -0
  65. data/test/dummy/config/initializers/assets.rb +8 -0
  66. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  67. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  68. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/test/dummy/config/initializers/inflections.rb +16 -0
  70. data/test/dummy/config/initializers/mime_types.rb +4 -0
  71. data/test/dummy/config/initializers/session_store.rb +3 -0
  72. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  73. data/test/dummy/config/locales/en.yml +23 -0
  74. data/test/dummy/config/routes.rb +8 -0
  75. data/test/dummy/config/secrets.yml +22 -0
  76. data/test/dummy/config.ru +4 -0
  77. data/test/dummy/db/development.sqlite3 +0 -0
  78. data/test/dummy/db/migrate/20141014142634_create_comments.rb +10 -0
  79. data/test/dummy/db/migrate/20141014142659_create_posts.rb +10 -0
  80. data/test/dummy/db/schema.rb +30 -0
  81. data/test/dummy/log/development.log +15567 -0
  82. data/test/dummy/public/404.html +67 -0
  83. data/test/dummy/public/422.html +67 -0
  84. data/test/dummy/public/500.html +66 -0
  85. data/test/dummy/public/favicon.ico +0 -0
  86. data/test/dummy/test/controllers/comments_controller_test.rb +49 -0
  87. data/test/dummy/test/controllers/posts_controller_test.rb +49 -0
  88. data/test/dummy/test/fixtures/comments.yml +9 -0
  89. data/test/dummy/test/fixtures/posts.yml +9 -0
  90. data/test/dummy/test/helpers/comments_helper_test.rb +4 -0
  91. data/test/dummy/test/helpers/posts_helper_test.rb +4 -0
  92. data/test/dummy/test/models/comment_test.rb +7 -0
  93. data/test/dummy/test/models/post_test.rb +7 -0
  94. data/test/dummy/tmp/cache/assets/development/sprockets/0dd5163be147a1ee2f93f5abb9a0fd32 +0 -0
  95. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  96. data/test/dummy/tmp/cache/assets/development/sprockets/1e8f75a6b5b33970fb8e397347caa0a1 +0 -0
  97. data/test/dummy/tmp/cache/assets/development/sprockets/206236caf137ae7dd3cae0aac897f4b2 +0 -0
  98. data/test/dummy/tmp/cache/assets/development/sprockets/24204f742af588c8166d3160b500d20f +0 -0
  99. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  100. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  101. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  102. data/test/dummy/tmp/cache/assets/development/sprockets/37c31816befce62c4f5d52026a23287d +0 -0
  103. data/test/dummy/tmp/cache/assets/development/sprockets/412ab75ab0fc70ac2d7f96418d4c1d43 +0 -0
  104. data/test/dummy/tmp/cache/assets/development/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
  105. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  106. data/test/dummy/tmp/cache/assets/development/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
  107. data/test/dummy/tmp/cache/assets/development/sprockets/5eccfa2606a027a0b509bdb46f03d701 +0 -0
  108. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/73510521b58326509331d135128ad92e +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/8244190c3c743ce907b74854faabcb0b +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/8288ddc9a4e9f4196c50036ee1eda4b8 +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/886a4f506bfbabff5d6b407aedbb80d0 +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/952d783e1981cc269524cb5a2890409d +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/9c7264225a395d67bc2a2d9181a19571 +0 -0
  115. data/test/dummy/tmp/cache/assets/development/sprockets/aa844f54ad5b802f23b19beb26e81435 +0 -0
  116. data/test/dummy/tmp/cache/assets/development/sprockets/ae2c9e8cd2d7afe29ae08c4e049fb57a +0 -0
  117. data/test/dummy/tmp/cache/assets/development/sprockets/b3ee3550542b56da2fa6ed034609648c +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/b86ae80f0c5c9fda3e212df5e11179c7 +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/b9de2fc513b54720f71ab4d2a2df3004 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/c40e7666f601d5bab36418512d6b76ee +0 -0
  121. data/test/dummy/tmp/cache/assets/development/sprockets/c5cb5b72ad5b8996bce2c68b02dff3a5 +0 -0
  122. data/test/dummy/tmp/cache/assets/development/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
  123. data/test/dummy/tmp/cache/assets/development/sprockets/cba44a33ec96893200b56f4695586826 +0 -0
  124. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  125. data/test/dummy/tmp/cache/assets/development/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
  126. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  127. data/test/dummy/tmp/cache/assets/development/sprockets/e1ca254e5fdbd2901067c0a9d95e6dd5 +0 -0
  128. data/test/dummy/tmp/cache/assets/development/sprockets/e584db490f8a31d32e707b821c61fa75 +0 -0
  129. data/test/dummy/tmp/cache/assets/development/sprockets/e912bd2d77f53416b8fa30878918d082 +0 -0
  130. data/test/dummy/tmp/cache/assets/development/sprockets/f13f0412b3245894f220e57919843e97 +0 -0
  131. data/test/dummy/tmp/cache/assets/development/sprockets/f3dabd6fc74da6af45a775c1ddb019f7 +0 -0
  132. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  133. data/test/helpers/quick_dry/quick_dry_helper_test.rb +6 -0
  134. data/test/integration/navigation_test.rb +10 -0
  135. data/test/quick_dry_test.rb +7 -0
  136. data/test/test_helper.rb +15 -0
  137. metadata +307 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9db6a676c18b25b55522e0601930eb7b42c8c15
4
- data.tar.gz: 3c5287f688a730091eef4e52467950d8e88730c8
3
+ metadata.gz: f307bb47a9ac23afa574ac625cf480ae08542c62
4
+ data.tar.gz: 3f1981082fa30267b9e274e94bd96e29844a3428
5
5
  SHA512:
6
- metadata.gz: 4e4c11ba0ddee7979de5556dd5386dec4919e77ffa8d1dbf56bfb6e3f7e8ae317ec698e1928663361e0b9ee3f7180073a9ea9a4d5753759603e618799365379b
7
- data.tar.gz: 231d353f942e737e20fcb64d516fc28f4bdc66ffdc6816ad4fb914a718690773d9ee69a167bfe3ad3ae25539c0bc17cf6d69314c44198f335c66cd94e9239051
6
+ metadata.gz: f10a829b9bd2540bceed1270028dd258f1d28e87644853dd5e42f6c238e59eb93e95e6fad59e9c45c7ab67a3bc2e64de26215beabe7d2d787e0d42a5fa5706aa
7
+ data.tar.gz: b02efee9e8f9c30b4cb92b5a33ea3de8b89f81e24fdcc16c32a45f7d5d49b17a0741c312a207d19cf292fc5547dd31c0aa89ce4cc52fd0ecae4ea63c5fa0362e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = QuickDry
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'QuickDry'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ module QuickDry
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,195 @@
1
+ require_dependency "quick_dry/application_controller"
2
+
3
+ module QuickDry
4
+ class QuickDryController < ApplicationController
5
+ protect_from_forgery #unless Rails.env = "development"
6
+ before_action :instantiate_paths
7
+
8
+ # GET /customer_orders
9
+ # GET /customer_orders.json
10
+ def index
11
+ # results = get_paged_search_results(params,user:current_user)
12
+ # params = results[:params]
13
+ @instances = get_model.all
14
+ render 'quick_dry/index'
15
+ end
16
+
17
+ def new
18
+ @instance = get_model.new
19
+ render 'quick_dry/new'
20
+ end
21
+
22
+ def show
23
+ @instance = get_model.find(params[:id])
24
+ render 'quick_dry/show'
25
+ end
26
+
27
+ def create
28
+ @instance = get_model.new(instance_params)
29
+
30
+ if @instance.save
31
+ flash[:notice] = 'Comment was successfully created.'
32
+ render 'quick_dry/show'
33
+ else
34
+ render 'quick_dry/new'
35
+ end
36
+ end
37
+
38
+ def edit
39
+ @instance = get_model.find(params[:id])
40
+ render 'quick_dry/edit'
41
+ end
42
+
43
+ def update
44
+ @instance = get_model.find(params[:id])
45
+
46
+ if @instance.update(instance_params)
47
+ flash[:notice] = "#{get_model.to_s} was successfully updated."
48
+ render 'quick_dry/show'
49
+ else
50
+ # flash[:error] = '#{get_model.to_s} could not be updated.'
51
+ render 'quick_dry/edit'
52
+ end
53
+ end
54
+
55
+ def destroy
56
+ @instance = get_model.find(params[:id]).destroy
57
+ # flash[:notice] = "#{get_model.to_s} was successfully destroyed."
58
+ redirect_to "/#{get_model.model_name.route_key}", notice: "#{get_model.to_s} was successfully destroyed."
59
+ end
60
+
61
+ # Never trust parameters from the scary internet, only allow the white list through.
62
+ def instance_params
63
+ model = get_model
64
+ # get all params except for id, and the standard dates
65
+ params.require(model.model_name.singular_route_key.to_sym).permit(model.attribute_names.collect{|x| x.to_sym} - [:id,:created_at,:updated_at])
66
+ end
67
+
68
+ def append_route(proc:nil,&block)
69
+ begin
70
+ _routes = Rails.application.routes
71
+ _routes.disable_clear_and_finalize = true
72
+ _routes.clear!
73
+ Rails.application.routes_reloader.paths.each{ |path| load(path) }
74
+
75
+ _routes.draw &proc unless proc.blank?
76
+ _routes.draw &block if block_given? and proc.blank?
77
+
78
+ _routes.finalize!
79
+ ensure
80
+ _routes.disable_clear_and_finalize = false
81
+ end
82
+ end
83
+
84
+ alias_method :append_routes, :append_route
85
+
86
+ def instantiate_paths
87
+ route = eval %(lambda {resources :#{get_model.model_name.route_key}, controller: 'quick_dry'})
88
+ append_route proc:route
89
+ # append_route {resources get_model.model_name.route_key.to_sym, path: 'quick_dry'}
90
+ # routes= Rails.application.routes.routes.map { |route| {alias: route.name, path: route.path.spec.to_s, method: "#{route.defaults[:controller]}##{route.defaults[:action]}"}}
91
+ end
92
+
93
+ # this will only work in conjunction with the routing provided with the engine
94
+ def get_model
95
+ model = request.params[:table_name].classify.constantize unless request.params[:table_name].blank?
96
+ # model.blank? ? return nil : return model
97
+ end
98
+
99
+ # Assumes the existance of a User model
100
+ def get_paged_search_results(params,user:nil,model:nil)
101
+ params[:per_page] = 10 if params[:per_page].blank?
102
+ params[:page] = 1 if params[:page].blank?
103
+ # a ghetto user check, but for some reason a devise user is not a devise user...
104
+ user = User.new if user.blank? or !user.class.to_s == User.to_s
105
+
106
+ # get the model in question
107
+ # there has got to be a better way to do this... I just can't find it
108
+ # model = params[:controller].blank? ? self.class.name.gsub('Controller','').singularize.constantize : params[:controller].classify.constantize
109
+ if model.blank?
110
+ model = request.params[:table_name].classify.constantize unless request.params[:table_name].blank?
111
+ return nil if model.blank?
112
+ end
113
+
114
+ # initialize un-paged filtered result set
115
+ result_set = model.none
116
+
117
+ # create where clauses to filter result to just the customers the current user has access to
118
+ customer_filter = ""
119
+ user.customers.each do |cust|
120
+ if model.column_names.include? "cust_id"
121
+ customer_filter << "(cust_id = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
122
+ elsif model.attribute_alias? "cust_id"
123
+ customer_filter << "(#{model.attribute_alias "cust_id"} = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
124
+ elsif model.column_names.include? "order_number"
125
+ customer_filter << "(order_number like '#{cust.prefix}%') OR " unless cust.prefix.blank?
126
+ elsif model.attribute_alias? "order_number"
127
+ customer_filter << "(#{model.attribute_alias "order_number"} like '#{cust.prefix}%') OR " unless cust.prefix.blank?
128
+ end
129
+ end
130
+ customer_filter << " (1=0)"
131
+
132
+ # create where clauses for each search parameter
133
+ if params[:columns].blank?
134
+ result_set = model.where(customer_filter)
135
+ else
136
+ where_clause = ""
137
+ params[:columns].each do |name, value|
138
+ where_clause << "(#{model.table_name}.#{name} like '%#{value}%') AND " unless value.blank?
139
+ end
140
+ where_clause << " (1=1)"
141
+
142
+ result_set = model.where(customer_filter).where(where_clause)
143
+ end
144
+
145
+ instances = model.paginate(page: params[:page], per_page: params[:per_page]).merge(result_set).order(updated_at: :desc)
146
+ return {instances:instances,params:params}
147
+ end
148
+
149
+ # # POST /customer_orders
150
+ # # POST /customer_orders.json
151
+ # def create
152
+ # @customer_order = CustomerOrder.new(customer_order_params)
153
+
154
+ # respond_to do |format|
155
+ # if @customer_order.save
156
+ # format.html { redirect_to @customer_order, notice: 'Customer order was successfully created.' }
157
+ # format.json { render :show, status: :created, location: @customer_order }
158
+ # else
159
+ # format.html { render :new }
160
+ # format.json { render json: @customer_order.errors, status: :unprocessable_entity }
161
+ # end
162
+ # end
163
+ # end
164
+
165
+ # # PATCH/PUT /customer_orders/1
166
+ # # PATCH/PUT /customer_orders/1.json
167
+ # def update
168
+ # respond_to do |format|
169
+ # if @customer_order.update(customer_order_params)
170
+ # format.html { redirect_to @customer_order, notice: 'Customer order was successfully updated.' }
171
+ # format.json { render :show, status: :ok, location: @customer_order }
172
+ # else
173
+ # format.html { render :edit }
174
+ # format.json { render json: @customer_order.errors, status: :unprocessable_entity }
175
+ # end
176
+ # end
177
+ # end
178
+
179
+ # # DELETE /customer_orders/1
180
+ # # DELETE /customer_orders/1.json
181
+ # def destroy
182
+ # @customer_order.destroy
183
+ # respond_to do |format|
184
+ # format.html { redirect_to customer_orders_url, notice: 'Customer order was successfully destroyed.' }
185
+ # format.json { head :no_content }
186
+ # end
187
+ # end
188
+
189
+ # private
190
+ # # Use callbacks to share common setup or constraints between actions.
191
+ # def set_customer_order
192
+ # @customer_order = CustomerOrder.find(params[:id])
193
+ # end
194
+ end
195
+ end
@@ -0,0 +1,4 @@
1
+ module QuickDry
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module QuickDry
2
+ module QuickDryHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>QuickDry</title>
5
+ <%= stylesheet_link_tag "quick_dry/application", media: "all" %>
6
+ <%= javascript_include_tag "quick_dry/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,26 @@
1
+ <%= form_for(instance, url:{controller:"quick_dry", action:method}) do |f| %>
2
+ <% if instance.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(instance.errors.count, "error") %> prohibited this comment from being saved:</h2>
5
+
6
+ <ul>
7
+ <% instance.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <% instance.attribute_names.each do |attr| %>
15
+ <% unless attr == "id" || attr == "created_at" || attr == "updated_at" %>
16
+ <div class="field">
17
+ <%= f.label attr.to_sym %><br>
18
+ <%= f.text_area attr.to_sym %>
19
+ </div>
20
+ <% end %>
21
+ <% end %>
22
+
23
+ <div class="actions">
24
+ <%= f.submit %>
25
+ </div>
26
+ <% end %>
@@ -0,0 +1,31 @@
1
+ <% model = @instances.class.superclass.to_s == "ActiveRecord::Relation" ? instances.model : instances.class %>
2
+
3
+ <h1><%= model.model_name.human.pluralize %></h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <% model.column_names.each do |name| %>
9
+ <th><%= model.human_attribute_name(name) %></th>
10
+ <% end %>
11
+ <th colspan="3"></th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% instances.each do |instance| %>
16
+ <tr>
17
+ <% instance.attribute_names.each do |attr| %>
18
+ <td><%= instance[attr.to_sym] %></td>
19
+ <% end %>
20
+ <td><%= link_to 'Show', "/#{model.model_name.route_key}/#{instance.id}" %></td>
21
+ <td><%= link_to 'Edit', "/#{model.model_name.route_key}/#{instance.id}/edit" %></td>
22
+ <td><%= link_to 'Destroy', "/#{model.model_name.route_key}/#{instance.id}", method: :delete, data: { confirm: 'Are you sure?' } %></td>
23
+
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <br>
30
+
31
+ <%= link_to "New #{model.model_name.human}", "/#{model.model_name.route_key}/new" %>
@@ -0,0 +1,10 @@
1
+ <%
2
+ instance = @instance
3
+ model = @instance.class
4
+ %>
5
+ <h1>Editing <%= model.model_name.human.downcase %></h1>
6
+
7
+ <%= render partial:'quick_dry/form',locals:{instance:instance, method:"update"} %>
8
+
9
+ <%= link_to 'Show', "/#{model.model_name.route_key}/#{instance.id}" %> |
10
+ <%= link_to 'Back', "/#{model.model_name.route_key}" %>
@@ -0,0 +1 @@
1
+ <%= render partial: 'quick_dry/model_table', locals: {instances:@instances} %>
@@ -0,0 +1,10 @@
1
+ <%
2
+ instance = @instance
3
+ model = @instance.class
4
+ %>
5
+
6
+ <h1>New <%= model.model_name.singular_route_key %></h1>
7
+
8
+ <%= render partial:'quick_dry/form',locals:{instance:instance, method:"create"} %>
9
+
10
+ <%= link_to 'Back', "/#{model.model_name.route_key}" %>
@@ -0,0 +1,12 @@
1
+ <% model = @instance.class %>
2
+
3
+ <p id="notice"><%= notice %></p>
4
+
5
+ <% @instance.attribute_names.each do |attr| %>
6
+ <p>
7
+ <strong><%= model.human_attribute_name(attr)%></strong>
8
+ <%= @instance[attr] %>
9
+ </p>
10
+ <% end %>
11
+ <%= link_to 'Edit', "/#{model.model_name.route_key}/#{@instance.id}/edit" %> |
12
+ <%= link_to 'Back', "/#{model.model_name.route_key}" %>
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ QuickDry::Engine.routes.draw do
2
+
3
+ # put these at the end of the routes.rb so as not to interfere with default rails routes
4
+ get '/:table_name(.:format)', to: 'quick_dry#index', table_name:/[^\/]*/, as: :instances
5
+ post '/:table_name(.:format)', to: 'quick_dry#create', table_name:/[^\/]*/
6
+ get '/:table_name/:id(.:format)', to: 'quick_dry#show', table_name:/[^\/]*/, id:/[\d]*/,as: :instance
7
+ put '/:table_name/:id(.:format)', to: 'quick_dry#update', table_name:/[^\/]*/, id:/[\d]*/
8
+ patch '/:table_name/:id(.:format)', to: 'quick_dry#update', table_name:/[^\/]*/, id:/[\d]*/
9
+ delete '/:table_name/:id(.:format)', to: 'quick_dry#destroy',table_name:/[^\/]*/, id:/[\d]*/
10
+ get '/:table_name/:id/edit(.:format)', to: 'quick_dry#edit', table_name:/[^\/]*/, id:/[\d]*/,as: :edit_instance
11
+ get '/:table_name/new(.:format)', to: 'quick_dry#new', table_name:/[^\/]*/, as: :new_instance
12
+
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ module QuickDry
2
+ class Engine < ::Rails::Engine
3
+ require 'jquery-rails'
4
+ isolate_namespace QuickDry
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module QuickDry
2
+ VERSION = "0.0.1"
3
+ end
data/lib/quick_dry.rb CHANGED
@@ -1,5 +1,4 @@
1
- class QuickDry
2
- def self.test
3
- puts "Hello World!"
4
- end
1
+ require "quick_dry/engine"
2
+
3
+ module QuickDry
5
4
  end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :quick_dry do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module QuickDry
4
+ class QuickDryControllerTest < ActionController::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */