0
POST 배열에서 param을 가져 와서 MySQL 데이터베이스에 삽입하는 데 시간이 많이 걸립니다. 파일은 파일 이름을 가져 와서 SQL 문에서 값으로 사용해야하는 RAILS 3 컨트롤러로 제출됩니다.Ajax가 POST 데이터를 Rails 3의 데이터베이스에 삽입하지 않았습니다.
def upload
@item= Item.new(params[:qqfile])
Rails.logger.info("PARAMS: #{params.inspect}")
# if params array contains :qqfile
unless params[:qqfile].empty?
# model should:
# copy file to uploads directory
render_success
if @item.save
else
render :text => 'database did not save'
end
# redirect to render success action
else
render :text => '{success:false}'
end
end
로그 쿼리가 실행되고 있는지 보여줍니다하지만 NULL 값 : 이것은 내 컨트롤러
Started POST "/item/upload?qqfile=1eCH6.jpg" for 127.0.0.1 at Fri Jan 07 09:16:0
9 -0700 2011
Processing by ItemController#upload as HTML
Parameters: {"qqfile"=>"1eCH6.jpg"}
PARAMS: {"qqfile"=>"1eCH6.jpg", "controller"=>"item", "action"=>"upload"}
Rendered text template (0.0ms)
SQL (0.0ms) INSERT INTO `items` (`name`, `qqfile`, `created_at`, `updated_at`
) VALUES (NULL, NULL, '2011-01-07 16:16:10', '2011-01-07 16:16:10')
Completed 200 OK in 359ms (Views: 16.0ms | ActiveRecord: 0.0ms)
의 핵심은 배열이있다. 컨트롤러가 SQL 쿼리의 값에 해당 값을 사용하지 않는 이유가 혼란 스럽습니다.
실제 양식을 제출하기 전에 발생하는 것은 ajax 업로드입니다. 클립 클립은 일반 파일 업로드에 관해서는 굉장합니다 ... 그러나 진행 막대와 함께 아약스를 할 때 그렇게 좋지는 않습니다. –