Ich bekomme [Objekt Objekt] auf meine Thumbnails (das Hintergrundbild ist der Bereich, wo Sie klicken können, um Fotos hochzuladen ... Ich bin nicht sicher, wie Sie die normale Box ähnlich dem Beispiel in http://www.dropzonejs.com/ laden)Ruby on Rails: Dropzone js, bekommen [Objekt Objekt], aber warum?
Ansicht
<%= simple_form_for @project do |f| %>
<div class="dropzone dz-clickable dz-square" id="mydrop">
<div class="dz-default dz-message" data-dz-message=""></div>
<div id="bi_previews"></div>
<div class="fallback">
<%= f.file_field :beautiful_image %></div>
</div>
</div>
<% end %>
Coffee
$(document).on 'ready page:load', ->
Dropzone.autoDiscover = false
$('div#mydrop').dropzone
url: '/projects'
previewsContainer: "#bi_previews"
headers: "X-CSRF-Token" : $('meta[name="csrf-token"]').attr('content')
paramName: "project[beautiful_image]"
init: ->
@on 'success', (file, json) ->
@on 'addedfile', (file) ->
@on 'drop', (file) ->
alert 'file'
return
return
routes.rb
Rails.application.routes.draw do
devise_for :users
resources :projects
Controller
def project_params
params.require(:project).permit(
:user_id, :beautiful_image, :title_name, :remove_project_images_files, project_images_files: [],
project_images_attributes: [:id, :project_id, :photo, :_destroy]).merge(user_id: current_user.id)
end
Modell
has_attached_file :beautiful_image, :styles => { :large => "800x800>", :medium => "500x500>", :thumb => "150x150#" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :beautiful_image, content_type: /\Aimage\/.*\Z/
EDIT
Posting-Controller pro Kommentar requets
def new
@project = Project.new
@gear = Gear.new
@project.gears.build
@project.project_images.build
end
def edit
@project = Project.find(params[:id])
end
def create
@project = Project.new(project_params)
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was successfully created.' }
format.json { render :show, status: :created, location: @project }
else
format.html { render :new }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
wie sollte ich die Seite überprüft haben; Es gibt nur ein Beispiel an der Spitze. Ich denke, es ist nicht mit Thumbnail konfiguriert. Wo ist das Beispiel, das du siehst? – songyy
@songyy was meinst du? Es gibt einen Abschnitt "Probieren Sie es aus". Laden Sie ein beliebiges Bild hoch, und nach dem Upload sehen Sie die Miniaturansichten – hellomello
. Ich kann ein Miniaturbild sehen, aber hier ist nichts Popup, wenn ich auf das Miniaturbild schwebe. Gibt es etwas, was ich verpasst habe? – songyy