diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index e989a8a..8347aa7 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -31,13 +31,10 @@ def create errors = [] parameters[:files].each do |f| tmp = {:title => parameters[:title], :private => parameters[:private], :tags => parameters[:tags], :file => f} - # byebug @image = Image.create(tmp) - # byebug if !(@image.save) - # byebug render action: :upload end @@ -51,8 +48,10 @@ def create # PATCH/PUT /images/1 # PATCH/PUT /images/1.json def update + respond_to do |format| - if @image.update(update_params) + + if @image.update(update_params[:image]) format.html { redirect_to @image, notice: 'Image was successfully updated.' } format.json { render :show, status: :ok, location: @image } else @@ -81,18 +80,12 @@ def destroy_all end end - - def download - send_data @resume, type: "application/pdf", disposition: "attachment" - end - def download_all files = [] imgs = Image.all imgs.each do |img| files << img.file end - # byebug send_zip files # send_data @resume, type: "application/pdf", disposition: "attachment" @@ -109,14 +102,13 @@ def set_image # Only allow a list of trusted parameters through. def create_params params.require(:files) - # byebug - params.require(:private) - params.permit(:title, :tags, :private, files: []) + params.permit(:title, :tags, files: []) end # Only allow a list of trusted parameters through. def update_params - params.permit(:title, :tags, :private) + params.require(:image) + params.permit(:image => [:title, :tags]) end end diff --git a/app/views/images/edit.html.erb b/app/views/images/edit.html.erb index 9ee2fab..4015dbe 100644 --- a/app/views/images/edit.html.erb +++ b/app/views/images/edit.html.erb @@ -1,6 +1,6 @@ -

Editing Image

+

Edit Image

-<%= form_with(url: image_path(@image), method: "put", :html => {:class => "form-horizontal center"}) do |form| %> +<%= form_with(model: @image, :class => "form-horizontal center") do |form| %>
<%= form.label(:title, "Image Title:") %> <%= form.text_field :title, :value => @image.title %> @@ -9,14 +9,9 @@ <%= form.label(:tags, "Choose Tags:") %> <%= form.text_field :tags, :value => @image.tags%>
-
- <%= form.label(:private, "Make Picture Public:") %> - <%= form.check_box :private %> -
<%= submit_tag("Save", :class => "btn btn-light") %> - <%= link_to 'Back', @image , :class => "btn btn-light"%> - <%= button_to "Delete", { controller: :images, action: :destroy, id: @image.id }, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn btn-light" %> - - <% end %> + +<%= link_to 'Back', @image , :class => "btn btn-light"%> +<%= button_to "Delete", { controller: :images, action: :destroy, id: @image.id }, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn btn-light" %> diff --git a/app/views/images/index.html.erb b/app/views/images/index.html.erb index 187010e..f7b561d 100644 --- a/app/views/images/index.html.erb +++ b/app/views/images/index.html.erb @@ -1,33 +1,34 @@ +
+ <% if params[:uploaded_success] %> + + <% end %> -<% if params[:uploaded_success] %> - -<% end %> -<%= paginate @images %> + <%= paginate @images %> + +
+ <% @images.each do |img| %> +
+
+ <%= image_tag img.file , :width => "100%" %> +
+

<%= img.title %>

-
- <% @images.each do |img| %> -
-
- <%= image_tag img.file , :width => "100%" %> -
-

<%= img.title %>

+ <% unless img.tags.empty? %> +

Tags: <%= img.tags %>

+ <% end %> - <% if img.tags %> -

Tags: <%= img.tags %>

- <% end %> + <%= link_to "View", image_path(img), :class => "btn btn-light" %> - <%= link_to "View", image_path(img), :class => "btn btn-light" %> +
-
- - <% end %> + <% end %>
diff --git a/app/views/images/show.html.erb b/app/views/images/show.html.erb index f78cc3e..271d102 100644 --- a/app/views/images/show.html.erb +++ b/app/views/images/show.html.erb @@ -7,16 +7,14 @@

<%= @image.title %>

- <% if @image.tags %> + <% unless @image.tags.empty? %>

Tags: <%= @image.tags %>

<% end %> <%= link_to 'Edit', edit_image_path(@image), :class => "btn btn-light"%> - <%= link_to "Download", download_image_path(@image), "data-turbolinks" => false, :class => "btn btn-light" %> - + <%= link_to "Download", rails_blob_path(@image.file, disposition: 'attachment'), :class => "btn btn-light" %> <%= link_to 'Back', root_path , :class => "btn btn-light"%> -
diff --git a/app/views/images/upload.html.erb b/app/views/images/upload.html.erb index 248e178..2336522 100644 --- a/app/views/images/upload.html.erb +++ b/app/views/images/upload.html.erb @@ -20,10 +20,7 @@ <%= form.label(:tags, "Choose Tags:") %> <%= form.text_field :tags%>
-
- <%= form.label(:private, "Make Picture Public:") %> - <%= form.check_box :private %> -
+ <%= submit_tag("Upload", :class => "btn btn-primary") %> diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb new file mode 100644 index 0000000..cc107ec --- /dev/null +++ b/app/views/kaminari/_first_page.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %> +
  • diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb new file mode 100644 index 0000000..d241fc4 --- /dev/null +++ b/app/views/kaminari/_gap.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %> +
  • diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb new file mode 100644 index 0000000..9a7584e --- /dev/null +++ b/app/views/kaminari/_last_page.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %> +
  • diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb new file mode 100644 index 0000000..7ca72a8 --- /dev/null +++ b/app/views/kaminari/_next_page.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %> +
  • diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb new file mode 100644 index 0000000..3b752b8 --- /dev/null +++ b/app/views/kaminari/_page.html.erb @@ -0,0 +1,9 @@ +<% if page.current? %> +
  • + <%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link' %> +
  • +<% else %> +
  • + <%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link' %> +
  • +<% end %> diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb new file mode 100644 index 0000000..bb5ed0f --- /dev/null +++ b/app/views/kaminari/_paginator.html.erb @@ -0,0 +1,17 @@ +<%= paginator.render do %> + +<% end %> diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb new file mode 100644 index 0000000..c7803fa --- /dev/null +++ b/app/views/kaminari/_prev_page.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %> +
  • diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 375a2c1..0f40861 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,11 +13,11 @@