uploadcare-rails 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +5 -16
  3. data/lib/generators/templates/uploadcare_config_template.erb +138 -0
  4. data/lib/generators/uploadcare_config_generator.rb +7 -4
  5. data/lib/uploadcare/errors/type_error.rb +7 -0
  6. data/lib/uploadcare/rails/action_view/uploadcare_include_tags.rb +48 -0
  7. data/lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb +57 -0
  8. data/lib/uploadcare/rails/active_record/mount_uploadcare_file.rb +62 -0
  9. data/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb +58 -0
  10. data/lib/uploadcare/rails/api/rest/base.rb +14 -0
  11. data/lib/uploadcare/rails/api/rest/conversion_api.rb +42 -0
  12. data/lib/uploadcare/rails/api/rest/file_api.rb +69 -0
  13. data/lib/uploadcare/rails/api/rest/group_api.rb +48 -0
  14. data/lib/uploadcare/rails/api/rest/project_api.rb +27 -0
  15. data/lib/uploadcare/rails/api/rest/webhook_api.rb +45 -0
  16. data/lib/uploadcare/rails/api/upload/base.rb +13 -0
  17. data/lib/uploadcare/rails/api/upload/upload_api.rb +53 -0
  18. data/lib/uploadcare/rails/configuration.rb +57 -0
  19. data/lib/uploadcare/rails/engine.rb +13 -17
  20. data/lib/uploadcare/rails/jobs/delete_file_job.rb +14 -0
  21. data/lib/uploadcare/rails/jobs/store_file_job.rb +14 -0
  22. data/lib/uploadcare/rails/jobs/store_group_job.rb +14 -0
  23. data/lib/uploadcare/rails/objects/concerns/loadable.rb +46 -0
  24. data/lib/uploadcare/rails/objects/file.rb +40 -20
  25. data/lib/uploadcare/rails/objects/group.rb +51 -57
  26. data/lib/uploadcare/rails/services/files_count_extractor.rb +14 -0
  27. data/lib/uploadcare/rails/services/id_extractor.rb +15 -0
  28. data/lib/uploadcare/rails/transformations/image_transformations.rb +45 -0
  29. data/lib/uploadcare/rails/version.rb +3 -1
  30. data/lib/uploadcare/rails.rb +10 -0
  31. data/lib/uploadcare-rails.rb +27 -16
  32. data/spec/fixtures/kitten.jpeg +0 -0
  33. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document.yml +62 -0
  34. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document_with_error.yml +62 -0
  35. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video.yml +62 -0
  36. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video_with_error.yml +62 -0
  37. data/spec/fixtures/vcr_cassettes/conversion_api_get_document_conversion_status.yml +59 -0
  38. data/spec/fixtures/vcr_cassettes/conversion_api_get_video_conversion_status.yml +59 -0
  39. data/spec/fixtures/vcr_cassettes/file_api_copy_file.yml +60 -0
  40. data/spec/fixtures/vcr_cassettes/file_api_delete_file.yml +58 -0
  41. data/spec/fixtures/vcr_cassettes/file_api_delete_files.yml +58 -0
  42. data/spec/fixtures/vcr_cassettes/file_api_get_file.yml +58 -0
  43. data/spec/fixtures/vcr_cassettes/file_api_get_files.yml +61 -0
  44. data/spec/fixtures/vcr_cassettes/file_api_load_file.yml +57 -0
  45. data/spec/fixtures/vcr_cassettes/file_api_store_file.yml +58 -0
  46. data/spec/fixtures/vcr_cassettes/file_api_store_files.yml +57 -0
  47. data/spec/fixtures/vcr_cassettes/group_api_create_group.yml +57 -0
  48. data/spec/fixtures/vcr_cassettes/group_api_get_group.yml +52 -0
  49. data/spec/fixtures/vcr_cassettes/group_api_get_groups.yml +57 -0
  50. data/spec/fixtures/vcr_cassettes/group_api_store_group.yml +57 -0
  51. data/spec/fixtures/vcr_cassettes/project_api_get_project.yml +59 -0
  52. data/spec/fixtures/vcr_cassettes/upload_upload_many_files.yml +55 -0
  53. data/spec/fixtures/vcr_cassettes/upload_upload_one_file.yml +105 -0
  54. data/spec/fixtures/vcr_cassettes/upload_upload_one_file_from_cdn.yml +111 -0
  55. data/spec/fixtures/vcr_cassettes/webhook_api_create_webhook.yml +59 -0
  56. data/spec/fixtures/vcr_cassettes/webhook_api_delete_webhook.yml +57 -0
  57. data/spec/fixtures/vcr_cassettes/webhook_api_get_webhooks.yml +59 -0
  58. data/spec/fixtures/vcr_cassettes/webhook_api_update_webhook.yml +59 -0
  59. data/spec/generators/uploadcare_config_generator_spec.rb +18 -26
  60. data/spec/spec_helper.rb +17 -69
  61. data/spec/support/generators.rb +8 -5
  62. data/spec/support/vcr.rb +14 -0
  63. data/spec/tmp/config/initializers/uploadcare.rb +138 -0
  64. data/spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb +40 -0
  65. data/spec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rb +46 -0
  66. data/spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb +33 -0
  67. data/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb +32 -0
  68. data/spec/uploadcare/rails/api/rest/conversion_api_spec.rb +110 -0
  69. data/spec/uploadcare/rails/api/rest/file_api_spec.rb +85 -0
  70. data/spec/uploadcare/rails/api/rest/group_api_spec.rb +61 -0
  71. data/spec/uploadcare/rails/api/rest/project_api_spec.rb +33 -0
  72. data/spec/uploadcare/rails/api/rest/webhook_api_spec.rb +59 -0
  73. data/spec/uploadcare/rails/api/upload/upload_api_spec.rb +82 -0
  74. data/spec/uploadcare/rails/jobs/delete_file_job_spec.rb +15 -0
  75. data/spec/uploadcare/rails/jobs/store_file_job_spec.rb +15 -0
  76. data/spec/uploadcare/rails/jobs/store_group_job_spec.rb +15 -0
  77. data/spec/uploadcare/rails/objects/file_spec.rb +77 -0
  78. data/spec/uploadcare/rails/objects/group_spec.rb +87 -0
  79. data/spec/uploadcare/rails/services/id_extractor_spec.rb +26 -0
  80. data/spec/uploadcare/rails/transformations/image_transformations_spec.rb +120 -0
  81. data/spec/uploadcare/rails_spec.rb +7 -0
  82. metadata +129 -351
  83. data/config/initializers/uploadcare.rb +0 -26
  84. data/config/uploadcare_defaults.yml +0 -12
  85. data/lib/generators/templates/uploadcare_config_template.yml +0 -67
  86. data/lib/tasks/uploadcare_rails_tasks.rake +0 -4
  87. data/lib/uploadcare/rails/action_view/include_tags.rb +0 -47
  88. data/lib/uploadcare/rails/action_view/uploader_tags.rb +0 -76
  89. data/lib/uploadcare/rails/active_record/has_file.rb +0 -92
  90. data/lib/uploadcare/rails/active_record/has_group.rb +0 -89
  91. data/lib/uploadcare/rails/active_record/has_object.rb +0 -9
  92. data/lib/uploadcare/rails/formtastic/formtastic.rb +0 -73
  93. data/lib/uploadcare/rails/operations.rb +0 -57
  94. data/lib/uploadcare/rails/settings.rb +0 -81
  95. data/lib/uploadcare/rails/simple_form/simple_form.rb +0 -63
  96. data/spec/caching/file_caching_spec.rb +0 -26
  97. data/spec/caching/group_caching_spec.rb +0 -40
  98. data/spec/dummy/README.rdoc +0 -28
  99. data/spec/dummy/Rakefile +0 -6
  100. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  101. data/spec/dummy/app/assets/javascripts/post_with_collections.js +0 -2
  102. data/spec/dummy/app/assets/javascripts/posts.js +0 -2
  103. data/spec/dummy/app/assets/javascripts/posts_with_collection_and_files.js +0 -2
  104. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  105. data/spec/dummy/app/assets/stylesheets/post_with_collections.css +0 -4
  106. data/spec/dummy/app/assets/stylesheets/posts.css +0 -4
  107. data/spec/dummy/app/assets/stylesheets/posts_with_collection_and_files.css +0 -4
  108. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
  109. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  110. data/spec/dummy/app/controllers/post_with_collections_controller.rb +0 -58
  111. data/spec/dummy/app/controllers/posts_controller.rb +0 -58
  112. data/spec/dummy/app/controllers/posts_with_collection_and_files_controller.rb +0 -58
  113. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  114. data/spec/dummy/app/helpers/post_with_collections_helper.rb +0 -2
  115. data/spec/dummy/app/helpers/posts_helper.rb +0 -2
  116. data/spec/dummy/app/helpers/posts_with_collection_and_files_helper.rb +0 -2
  117. data/spec/dummy/app/models/post.rb +0 -4
  118. data/spec/dummy/app/models/post_with_collection.rb +0 -4
  119. data/spec/dummy/app/models/posts_with_collection_and_file.rb +0 -4
  120. data/spec/dummy/app/views/layouts/application.html.erb +0 -16
  121. data/spec/dummy/app/views/post_with_collections/_form.html.erb +0 -25
  122. data/spec/dummy/app/views/post_with_collections/edit.html.erb +0 -6
  123. data/spec/dummy/app/views/post_with_collections/index.html.erb +0 -29
  124. data/spec/dummy/app/views/post_with_collections/new.html.erb +0 -5
  125. data/spec/dummy/app/views/post_with_collections/show.html.erb +0 -14
  126. data/spec/dummy/app/views/post_with_collections/show.json.jbuilder +0 -1
  127. data/spec/dummy/app/views/posts/_form.html.erb +0 -31
  128. data/spec/dummy/app/views/posts/edit.html.erb +0 -6
  129. data/spec/dummy/app/views/posts/index.html.erb +0 -37
  130. data/spec/dummy/app/views/posts/new.html.erb +0 -5
  131. data/spec/dummy/app/views/posts/post.json.builder +0 -1
  132. data/spec/dummy/app/views/posts/show.html.erb +0 -15
  133. data/spec/dummy/app/views/posts_with_collection_and_files/_form.html.erb +0 -27
  134. data/spec/dummy/app/views/posts_with_collection_and_files/edit.html.erb +0 -6
  135. data/spec/dummy/app/views/posts_with_collection_and_files/index.html.erb +0 -25
  136. data/spec/dummy/app/views/posts_with_collection_and_files/new.html.erb +0 -5
  137. data/spec/dummy/app/views/posts_with_collection_and_files/show.html.erb +0 -4
  138. data/spec/dummy/app/views/posts_with_collection_and_files/show.json.jbuilder +0 -1
  139. data/spec/dummy/bin/bundle +0 -3
  140. data/spec/dummy/bin/rails +0 -4
  141. data/spec/dummy/bin/rake +0 -4
  142. data/spec/dummy/config/application.rb +0 -23
  143. data/spec/dummy/config/boot.rb +0 -4
  144. data/spec/dummy/config/database.yml +0 -25
  145. data/spec/dummy/config/environment.rb +0 -5
  146. data/spec/dummy/config/environments/development.rb +0 -29
  147. data/spec/dummy/config/environments/production.rb +0 -80
  148. data/spec/dummy/config/environments/test.rb +0 -36
  149. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  150. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  151. data/spec/dummy/config/initializers/formtastic.rb +0 -111
  152. data/spec/dummy/config/initializers/inflections.rb +0 -16
  153. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  154. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  155. data/spec/dummy/config/initializers/session_store.rb +0 -3
  156. data/spec/dummy/config/initializers/simple_form.rb +0 -167
  157. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  158. data/spec/dummy/config/locales/en.yml +0 -23
  159. data/spec/dummy/config/locales/simple_form.en.yml +0 -31
  160. data/spec/dummy/config/routes.rb +0 -63
  161. data/spec/dummy/config/uploadcare.yml +0 -64
  162. data/spec/dummy/config.ru +0 -4
  163. data/spec/dummy/db/migrate/20171012001801_create_tables.rb +0 -27
  164. data/spec/dummy/db/migrate/20181001132710_add_other_file_to_post.rb +0 -8
  165. data/spec/dummy/db/migrate/20181001141434_add_other_file_to_post_with_collections.rb +0 -8
  166. data/spec/dummy/db/schema.rb +0 -39
  167. data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +0 -13
  168. data/spec/dummy/public/404.html +0 -58
  169. data/spec/dummy/public/422.html +0 -58
  170. data/spec/dummy/public/500.html +0 -57
  171. data/spec/dummy/public/favicon.ico +0 -0
  172. data/spec/helpers/form_helpers_has_file_spec.rb +0 -30
  173. data/spec/helpers/form_helpers_has_group_spec.rb +0 -30
  174. data/spec/helpers/form_helpers_spec.rb +0 -33
  175. data/spec/helpers/formtastic_spec.rb +0 -25
  176. data/spec/helpers/include_tags_spec.rb +0 -54
  177. data/spec/helpers/simple_form_spec.rb +0 -25
  178. data/spec/helpers/uploader_tags_spec.rb +0 -21
  179. data/spec/models/has_both_file_and_group_spec.rb +0 -43
  180. data/spec/models/has_file_spec.rb +0 -46
  181. data/spec/models/has_group_spec.rb +0 -57
  182. data/spec/models/has_several_files_spec.rb +0 -55
  183. data/spec/models/has_several_groups_spec.rb +0 -62
  184. data/spec/objects/file_spec.rb +0 -27
  185. data/spec/objects/group_spec.rb +0 -51
  186. data/spec/operations_spec.rb +0 -28
  187. data/spec/uploadcare/rails/settings_spec.rb +0 -136
  188. data/spec/uploadcare_rails_settings_spec.rb +0 -56
  189. data/spec/view.png +0 -0
  190. data/spec/view2.jpg +0 -0
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Uploadcare::Rails::Group, :vcr do
4
- let(:post) { PostWithCollection.new(title: 'Title', file: GROUP_CDN_URL) }
5
-
6
- after :each do
7
- Rails.cache.delete(GROUP_CDN_URL)
8
- end
9
-
10
- it 'should be not loaded by default' do
11
- expect(post.file).not_to be_loaded
12
- end
13
-
14
- it 'rails cache should be nil' do
15
- expect(Rails.cache.read(post.file.cdn_url)).to be_nil
16
- end
17
-
18
- it 'rails cache should updates after load call' do
19
- post.file.load!
20
- cached = Rails.cache.read GROUP_CDN_URL
21
-
22
- expect(cached).to be_a(Hash)
23
- expect(cached['datetime_created']).to be_a(String)
24
- end
25
-
26
- it 'group should stay loaded' do
27
- expect(post.file).not_to be_loaded
28
- post.file.load!
29
- expect(post.file).to be_loaded
30
- end
31
-
32
- it 'cached group should contained json representation of files',
33
- vcr: { cassette_name: 'group_cahsing_file_load'} do
34
- post.file.load!
35
- cached = Rails.cache.read GROUP_CDN_URL
36
-
37
- expect(cached).to be_a(Hash)
38
- expect(cached['files'].sample).to be_a(Hash)
39
- end
40
- end
@@ -1,28 +0,0 @@
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>.
data/spec/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
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
- Dummy::Application.load_tasks
@@ -1,13 +0,0 @@
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 .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,13 +0,0 @@
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 top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,56 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,58 +0,0 @@
1
- class PostWithCollectionsController < ApplicationController
2
- before_action :set_post_with_collection, only: [:show, :edit, :update, :destroy]
3
-
4
- # GET /post_with_collections
5
- def index
6
- @post_with_collections = PostWithCollection.all
7
- end
8
-
9
- # GET /post_with_collections/1
10
- def show
11
- end
12
-
13
- # GET /post_with_collections/new
14
- def new
15
- @post_with_collection = PostWithCollection.new
16
- end
17
-
18
- # GET /post_with_collections/1/edit
19
- def edit
20
- end
21
-
22
- # POST /post_with_collections
23
- def create
24
- @post_with_collection = PostWithCollection.new(post_with_collection_params)
25
-
26
- if @post_with_collection.save
27
- redirect_to @post_with_collection, notice: 'Post with collection was successfully created.'
28
- else
29
- render action: 'new'
30
- end
31
- end
32
-
33
- # PATCH/PUT /post_with_collections/1
34
- def update
35
- if @post_with_collection.update(post_with_collection_params)
36
- redirect_to @post_with_collection, notice: 'Post with collection was successfully updated.'
37
- else
38
- render action: 'edit'
39
- end
40
- end
41
-
42
- # DELETE /post_with_collections/1
43
- def destroy
44
- @post_with_collection.destroy
45
- redirect_to post_with_collections_url, notice: 'Post with collection was successfully destroyed.'
46
- end
47
-
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_post_with_collection
51
- @post_with_collection = PostWithCollection.find(params[:id])
52
- end
53
-
54
- # Only allow a trusted parameter "white list" through.
55
- def post_with_collection_params
56
- params.require(:post_with_collection).permit(:title, :file)
57
- end
58
- end
@@ -1,58 +0,0 @@
1
- class PostsController < ApplicationController
2
- before_action :set_post, only: [:show, :edit, :update, :destroy]
3
-
4
- # GET /posts
5
- def index
6
- @posts = Post.all
7
- end
8
-
9
- # GET /posts/1
10
- def show
11
- end
12
-
13
- # GET /posts/new
14
- def new
15
- @post = Post.new
16
- end
17
-
18
- # GET /posts/1/edit
19
- def edit
20
- end
21
-
22
- # POST /posts
23
- def create
24
- @post = Post.new(post_params)
25
-
26
- if @post.save
27
- redirect_to @post, notice: 'Post was successfully created.'
28
- else
29
- render action: 'new'
30
- end
31
- end
32
-
33
- # PATCH/PUT /posts/1
34
- def update
35
- if @post.update(post_params)
36
- redirect_to @post, notice: 'Post was successfully updated.'
37
- else
38
- render action: 'edit'
39
- end
40
- end
41
-
42
- # DELETE /posts/1
43
- def destroy
44
- @post.destroy
45
- redirect_to posts_url, notice: 'Post was successfully destroyed.'
46
- end
47
-
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_post
51
- @post = Post.find(params[:id])
52
- end
53
-
54
- # Only allow a trusted parameter "white list" through.
55
- def post_params
56
- params.require(:post).permit(:title, :file)
57
- end
58
- end
@@ -1,58 +0,0 @@
1
- class PostsWithCollectionAndFilesController < ApplicationController
2
- before_action :set_posts_with_collection_and_file, only: [:show, :edit, :update, :destroy]
3
-
4
- # GET /posts_with_collection_and_files
5
- def index
6
- @posts_with_collection_and_files = PostsWithCollectionAndFile.all
7
- end
8
-
9
- # GET /posts_with_collection_and_files/1
10
- def show
11
- end
12
-
13
- # GET /posts_with_collection_and_files/new
14
- def new
15
- @posts_with_collection_and_file = PostsWithCollectionAndFile.new
16
- end
17
-
18
- # GET /posts_with_collection_and_files/1/edit
19
- def edit
20
- end
21
-
22
- # POST /posts_with_collection_and_files
23
- def create
24
- @posts_with_collection_and_file = PostsWithCollectionAndFile.new(posts_with_collection_and_file_params)
25
-
26
- if @posts_with_collection_and_file.save
27
- redirect_to @posts_with_collection_and_file, notice: 'Posts with collection and file was successfully created.'
28
- else
29
- render action: 'new'
30
- end
31
- end
32
-
33
- # PATCH/PUT /posts_with_collection_and_files/1
34
- def update
35
- if @posts_with_collection_and_file.update(posts_with_collection_and_file_params)
36
- redirect_to @posts_with_collection_and_file, notice: 'Posts with collection and file was successfully updated.'
37
- else
38
- render action: 'edit'
39
- end
40
- end
41
-
42
- # DELETE /posts_with_collection_and_files/1
43
- def destroy
44
- @posts_with_collection_and_file.destroy
45
- redirect_to posts_with_collection_and_files_url, notice: 'Posts with collection and file was successfully destroyed.'
46
- end
47
-
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_posts_with_collection_and_file
51
- @posts_with_collection_and_file = PostsWithCollectionAndFile.find(params[:id])
52
- end
53
-
54
- # Only allow a trusted parameter "white list" through.
55
- def posts_with_collection_and_file_params
56
- params[:posts_with_collection_and_file]
57
- end
58
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,2 +0,0 @@
1
- module PostWithCollectionsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module PostsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module PostsWithCollectionAndFilesHelper
2
- end
@@ -1,4 +0,0 @@
1
- class Post < ActiveRecord::Base
2
- has_uploadcare_file :file
3
- has_uploadcare_file :other_file
4
- end
@@ -1,4 +0,0 @@
1
- class PostWithCollection < ActiveRecord::Base
2
- has_uploadcare_group :file
3
- has_uploadcare_group :other_file
4
- end
@@ -1,4 +0,0 @@
1
- class PostsWithCollectionAndFile < ActiveRecord::Base
2
- has_uploadcare_file :file
3
- has_uploadcare_group :group
4
- end
@@ -1,16 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag :application, media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag :application, 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- <%= include_uploadcare_widget_from_cdn %>
9
- <%= uploadcare_settings %>
10
- </head>
11
- <body>
12
-
13
- <%= yield %>
14
-
15
- </body>
16
- </html>
@@ -1,25 +0,0 @@
1
- <%= form_for(@post_with_collection) do |f| %>
2
- <% if @post_with_collection.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@post_with_collection.errors.count, "error") %> prohibited this post_with_collection from being saved:</h2>
5
-
6
- <ul>
7
- <% @post_with_collection.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :title %><br>
16
- <%= f.text_field :title %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :file %><br>
20
- <%= f.uploadcare_field :file %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
@@ -1,6 +0,0 @@
1
- <h1>Editing post_with_collection</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @post_with_collection %> |
6
- <%= link_to 'Back', post_with_collections_path %>
@@ -1,29 +0,0 @@
1
- <h1>Listing post_with_collections</h1>
2
-
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>Title</th>
7
- <th>File</th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
- </thead>
13
-
14
- <tbody>
15
- <% @post_with_collections.each do |post_with_collection| %>
16
- <tr>
17
- <td><%= post_with_collection.title %></td>
18
- <td><%= post_with_collection.file %></td>
19
- <td><%= link_to 'Show', post_with_collection %></td>
20
- <td><%= link_to 'Edit', edit_post_with_collection_path(post_with_collection) %></td>
21
- <td><%= link_to 'Destroy', post_with_collection, method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
- </tr>
23
- <% end %>
24
- </tbody>
25
- </table>
26
-
27
- <br>
28
-
29
- <%= link_to 'New Post with collection', new_post_with_collection_path %>
@@ -1,5 +0,0 @@
1
- <h1>New post_with_collection</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', post_with_collections_path %>
@@ -1,14 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <strong>Title:</strong>
5
- <%= @post_with_collection.title %>
6
- </p>
7
-
8
- <p>
9
- <strong>File:</strong>
10
- <%= @post_with_collection.file %>
11
- </p>
12
-
13
- <%= link_to 'Edit', edit_post_with_collection_path(@post_with_collection) %> |
14
- <%= link_to 'Back', post_with_collections_path %>
@@ -1 +0,0 @@
1
- json.extract! @post, :id, :title, :file, :group, :created_at, :updated_at
@@ -1,31 +0,0 @@
1
- <%= form_for(@post) do |f| %>
2
- <% if @post.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
-
6
- <ul>
7
- <% @post.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :title %><br>
16
- <%= f.text_field :title %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :file %><br>
20
- <%= f.uploadcare_field :file, {uploadcare: {multiple: false}, data: {multiple: true}} %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
26
-
27
-
28
-
29
- <%= simple_form_for(@post) do |f| %>
30
- <%= f.input :file, as: :uploadcare_uploader, uploadcare: {multiple: true} %>
31
- <% end %>
@@ -1,6 +0,0 @@
1
- <h1>Editing post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @post %> |
6
- <%= link_to 'Back', posts_path %>
@@ -1,37 +0,0 @@
1
- <h1>Listing posts</h1>
2
-
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>Title</th>
7
- <th>File</th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
- </thead>
13
-
14
- <tbody>
15
- <% @posts.each do |post| %>
16
- <tr>
17
- <td><%= post.title %></td>
18
- <td><%= post.file %></td>
19
- <td><%= link_to 'Show', post %></td>
20
- <td><%= link_to 'Edit', edit_post_path(post) %></td>
21
- <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
- </tr>
23
- <% end %>
24
- </tbody>
25
- </table>
26
-
27
- <br>
28
-
29
- <%= link_to 'New Post', new_post_path %>
30
-
31
- <br>
32
- <p>:uploadcare_uploader_tag test</p>
33
- <%= uploadcare_uploader_tag :file %>
34
-
35
- <br>
36
- <p>:uploadcare_uploader_field test</p>
37
- <%= uploadcare_uploader_field :post, :file %>
@@ -1,5 +0,0 @@
1
- <h1>New post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', posts_path %>
@@ -1 +0,0 @@
1
- json.extract! @post, :id, :title, :file, :group, :created_at, :updated_at
@@ -1,15 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <strong>Title:</strong>
5
- <%= @post.title %>
6
- </p>
7
-
8
- <p>
9
- <strong>File:</strong>
10
- <!-- <%= @post.file.try :image, false, width: "180px" %> -->
11
- <%= image_tag(@post.file)%>
12
- </p>
13
-
14
- <%= link_to 'Edit', edit_post_path(@post) %> |
15
- <%= link_to 'Back', posts_path %>
@@ -1,27 +0,0 @@
1
- <%= form_for(@posts_with_collection_and_file) do |f| %>
2
- <% if @posts_with_collection_and_file.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@posts_with_collection_and_file.errors.count, "error") %> prohibited this posts_with_collection_and_file from being saved:</h2>
5
-
6
- <ul>
7
- <% @posts_with_collection_and_file.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :title %><br>
16
- <%= f.text_field :title %>
17
- </div>
18
-
19
- <div class="field">
20
- <%= f.label :file %><br>
21
- <%= f.uploadcare_field :file, {uploadcare: {multiple: false}, data: {multiple: true}} %>
22
- </div>
23
-
24
- <div class="actions">
25
- <%= f.submit %>
26
- </div>
27
- <% end %>
@@ -1,6 +0,0 @@
1
- <h1>Editing posts_with_collection_and_file</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @posts_with_collection_and_file %> |
6
- <%= link_to 'Back', posts_with_collection_and_files_path %>