2013-09-17 2 views
0

Я использую загрузку rails jquery с помощью скрепки. Моя таблица обновляется с created_at и uploaded_at, но file_name, file_size и все пустые. И я не вижу файлы, загруженные.пустые загрузки файлов рельсы jquery uploader

Это жемчужина я использовал

gem 'jquery-rails' 
gem 'jquery-fileupload-rails' 
gem 'paperclip' 

Это мой uploads_controller

def create 
    @image = Upload.new(upload_params) 

    respond_to do |format| 
     if @image.save 
     format.html { 
      render :json => [@image.to_jq_upload].to_json, 
      :content_type => 'text/html', 
      :layout => false 
     } 
     format.json { render json: {files: [@image.to_jq_upload]}, status: :created, location: @image } 
     else 
     format.html { render action: "new" } 
     format.json { render json: @image.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

Поскольку я использую рельсы я использовал этот

private 
    def upload_params 
    params.require(:upload).permit(:post_id,:upload_file_name,:upload_file_size,:upload_content_type,:upload_updated_at) 
    end 

Это моя модель загрузки

has_attached_file :upload, :styles => { :medium => "300x300>", :thumb => "100x100>" } 

    include Rails.application.routes.url_helpers 

    def to_jq_upload 
    { 
     "name" => read_attribute(:upload_file_name), 
     "size" => read_attribute(:upload_file_size), 
     "url" => upload.url(:original), 
     "delete_url" => upload_path(self), 
     "delete_type" => "DELETE" 
    } 
    end 

ответ

0

избавиться от всего, что загружает файлы и изменить его просто: загрузить так

params.require(:upload).permit(:post_id,:upload) 
Смежные вопросы