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 @@ -
<%= img.title %>
-<%= 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" %> +<%= @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"%> -